浏览代码

[http] Allow for URI encodings within username and password

tags/v0.9.7
Michael Brown 16 年前
父节点
当前提交
816a32aaee
共有 1 个文件被更改,包括 15 次插入2 次删除
  1. 15
    2
      src/net/tcp/http.c

+ 15
- 2
src/net/tcp/http.c 查看文件

@@ -407,8 +407,21 @@ static void http_step ( struct process *process ) {
407 407
 
408 408
 		/* Construct authorisation, if applicable */
409 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 425
 			base64_encode ( user_pw, user_pw_base64 );
413 426
 		}
414 427
 

正在加载...
取消
保存