Skip to content

Commit 34ecd2f

Browse files
committed
bugfix: ngx.escape_uri() now uses uppercase hexadecimal digits for percent-encoding according to the recommendation in RFC 3986. thanks Piotr Sikora for the suggestion.
1 parent 5e94463 commit 34ecd2f

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/ngx_http_lua_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1769,7 +1769,7 @@ ngx_http_lua_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type)
17691769
{
17701770
ngx_uint_t n;
17711771
uint32_t *escape;
1772-
static u_char hex[] = "0123456789abcdef";
1772+
static u_char hex[] = "0123456789ABCDEF";
17731773

17741774
/* " ", "#", "%", "?", %00-%1F, %7F-%FF */
17751775

t/006-escape.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ __DATA__
2323
--- request
2424
GET /escape
2525
--- response_body
26-
a%20%e4%bd%a0
26+
a%20%E4%BD%A0
2727
2828
2929
@@ -48,7 +48,7 @@ a 你
4848
--- request
4949
GET /escape
5050
--- response_body
51-
a%20%e4%bd%a0
51+
a%20%E4%BD%A0
5252
5353
5454
@@ -73,7 +73,7 @@ a 你
7373
--- request
7474
GET /escape
7575
--- response_body
76-
a%2bb
76+
a%2Bb
7777
7878
7979
@@ -86,7 +86,7 @@ a%2bb
8686
--- request
8787
GET /escape
8888
--- response_body
89-
%22a%2fb%3d%7b%7d%3a%3c%3e%3b%26%5b%5d%5c%5e
89+
%22a%2Fb%3D%7B%7D%3A%3C%3E%3B%26%5B%5D%5C%5E
9090
9191
9292

t/020-subrequest.t

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ GET /lua
461461
--- request
462462
GET /lua
463463
--- response_body
464-
fo%3d=%3d%3e
464+
fo%3D=%3D%3E
465465
--- no_error_log
466466
[error]
467467
@@ -484,7 +484,7 @@ fo%3d=%3d%3e
484484
--- request
485485
GET /lua
486486
--- response_body_like chop
487-
^(?:fo%3d=%3d%3e\&%3d=%3a|%3d=%3a\&fo%3d=%3d%3e)$
487+
^(?:fo%3D=%3D%3E\&%3D=%3A|%3D=%3A\&fo%3D=%3D%3E)$
488488
--- no_error_log
489489
[error]
490490
--- no_error_log
@@ -1128,7 +1128,7 @@ hello world
11281128
--- request
11291129
GET /t?r[]=http%3A%2F%2Fajax.googleapis.com%3A80%2Fajax%2Flibs%2Fjquery%2F1.7.2%2Fjquery.min.js&r[]=http%3A%2F%2Fajax.googleapis.com%3A80%2Fajax%2Flibs%2Fdojo%2F1.7.2%2Fdojo%2Fdojo.js.uncompressed.js
11301130
--- response_body
1131-
r%5b%5d=http%3a%2f%2fajax.googleapis.com%3a80%2fajax%2flibs%2fjquery%2f1.7.2%2fjquery.min.js&r%5b%5d=http%3a%2f%2fajax.googleapis.com%3a80%2fajax%2flibs%2fdojo%2f1.7.2%2fdojo%2fdojo.js.uncompressed.js
1131+
r%5B%5D=http%3A%2F%2Fajax.googleapis.com%3A80%2Fajax%2Flibs%2Fjquery%2F1.7.2%2Fjquery.min.js&r%5B%5D=http%3A%2F%2Fajax.googleapis.com%3A80%2Fajax%2Flibs%2Fdojo%2F1.7.2%2Fdojo%2Fdojo.js.uncompressed.js
11321132
--- no_error_log
11331133
[error]
11341134

t/023-rewrite/subrequest.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ GET /lua
447447
--- request
448448
GET /lua
449449
--- response_body
450-
fo%3d=%3d%3e
450+
fo%3D=%3D%3E
451451

452452

453453

@@ -469,7 +469,7 @@ fo%3d=%3d%3e
469469
--- request
470470
GET /lua
471471
--- response_body_like chop
472-
^(?:fo%3d=%3d%3e\&%3d=%3a|%3d=%3a\&fo%3d=%3d%3e)$
472+
^(?:fo%3D=%3D%3E\&%3D=%3A|%3D=%3A\&fo%3D=%3D%3E)$
473473

474474

475475

t/024-access/subrequest.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ GET /lua
447447
--- request
448448
GET /lua
449449
--- response_body
450-
fo%3d=%3d%3e
450+
fo%3D=%3D%3E
451451

452452

453453

@@ -469,7 +469,7 @@ fo%3d=%3d%3e
469469
--- request
470470
GET /lua
471471
--- response_body_like chop
472-
^(?:fo%3d=%3d%3e\&%3d=%3a|%3d=%3a\&fo%3d=%3d%3e)$
472+
^(?:fo%3D=%3D%3E\&%3D=%3A|%3D=%3A\&fo%3D=%3D%3E)$
473473

474474

475475

0 commit comments

Comments
 (0)