Skip to content

Commit 691370e

Browse files
spacewanderagentzh
authored andcommitted
Revert "bugfix: ngx.escape_uri: we did not escape URI reserved chars. openresty#1124"
Commit f170505 breaks the compatibility with RFC 3986. Here is two reasons: 1. Quote from RFC 3986 Section 2.2: > A subset of the reserved characters (gen-delims) is used as delimiters of the generic URI components described in Section 3 Note that RFC 3986 says 'a subset of the reserved characters (gen-delims)', not all the reserved characters. The characters escaped in that commit are 'sub-delims'. They are not required to be escaped according to Section 2.2. 2. Refer to RFC 3986 "Appendix A. Collected ABNF for URI", sub-delims could be used as part of query and other components. This use case shows that sub-delims are valid in some component of URI. Therefore, it would be better if we don't escape them for URI component. Signed-off-by: Yichun Zhang (agentzh) <agentzh@gmail.com>
1 parent f170505 commit 691370e

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/ngx_http_lua_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1852,7 +1852,7 @@ ngx_http_lua_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type)
18521852
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
18531853

18541854
/* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */
1855-
0xfc009fff, /* 1111 1100 0000 0000 1001 1111 1111 1111 */
1855+
0xfc00987d, /* 1111 1100 0000 0000 1001 1000 0111 1101 */
18561856

18571857
/* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */
18581858
0x78000001, /* 0111 1000 0000 0000 0000 0000 0000 0001 */

t/006-escape.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ GET /t
193193
--- request
194194
GET /lua
195195
--- response_body
196-
-_.%21~%2A%27%28%29
196+
-_.!~*'()
197197
%2C%24%40%7C%60
198198
--- no_error_log
199199
[error]

t/030-uri-args.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,6 @@ GET /lua
14031403
--- request
14041404
GET /lua
14051405
--- response_body
1406-
args: foo=%2C%24%40%7C%60&bar=-_.%21~%2A%27%28%29
1406+
args: foo=%2C%24%40%7C%60&bar=-_.!~*'()
14071407
--- no_error_log
14081408
[error]

0 commit comments

Comments
 (0)