Browse Source

[http] Allow for URI encodings within username and password

tags/v0.9.7
Michael Brown 15 years ago
parent
commit
816a32aaee
1 changed files with 15 additions and 2 deletions
  1. 15
    2
      src/net/tcp/http.c

+ 15
- 2
src/net/tcp/http.c View File

407
 
407
 
408
 		/* Construct authorisation, if applicable */
408
 		/* Construct authorisation, if applicable */
409
 		if ( user_pw_len ) {
409
 		if ( user_pw_len ) {
410
-			snprintf ( user_pw, sizeof ( user_pw ), "%s:%s",
411
-				   user, password );
410
+			char *buf = user_pw;
411
+			ssize_t remaining = sizeof ( user_pw );
412
+			size_t len;
413
+
414
+			/* URI-decode the username and password */
415
+			len = uri_decode ( user, buf, remaining );
416
+			buf += len;
417
+			remaining -= len;
418
+			*(remaining--, buf++) = ':';
419
+			len = uri_decode ( password, buf, remaining );
420
+			buf += len;
421
+			remaining -= len;
422
+			assert ( remaining >= 0 );
423
+
424
+			/* Base64-encode the "user:password" string */
412
 			base64_encode ( user_pw, user_pw_base64 );
425
 			base64_encode ( user_pw, user_pw_base64 );
413
 		}
426
 		}
414
 
427
 

Loading…
Cancel
Save