-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix:ngx.encode_args() not escaped "|" to "%7c". see: https://en.wi… #542
Closed
+73
−36
Closed
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1bf4441
bugfix:ngx.encode_args() not escaped "|" to "%7c". see: https://en.wi…
goecho 5e3992e
bugfix:ngx.encode_args() not escaped "|",",","$","@","`";100% compati…
goecho b226e97
add a simple test case on ngx.encode_args()
goecho fb3ef85
Merge remote-tracking branch 'openresty-lua-nginx-module/master'
goecho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1841,6 +1841,26 @@ ngx_http_lua_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type) | |
/* ~}| {zyx wvut srqp onml kjih gfed cba` */ | ||
0x80000000, /* 1000 0000 0000 0000 0000 0000 0000 0000 */ | ||
|
||
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ | ||
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ | ||
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ | ||
0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */ | ||
}; | ||
|
||
/* not ALPHA, DIGIT, "-", ".", "_", "~" */ | ||
|
||
static uint32_t uri_component[] = { | ||
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ | ||
|
||
/* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */ | ||
0xfc009fff, /* 1111 1100 0000 0000 1001 1111 1111 1111 */ | ||
|
||
/* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */ | ||
0x78000001, /* 0111 1000 0000 0000 0000 0000 0000 0001 */ | ||
|
||
/* ~}| {zyx wvut srqp onml kjih gfed cba` */ | ||
0xb8000001, /* 1011 1000 0000 0000 0000 0000 0000 0001 */ | ||
|
||
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ | ||
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ | ||
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ | ||
|
@@ -1909,9 +1929,8 @@ ngx_http_lua_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type) | |
|
||
/* mail_auth is the same as memcached */ | ||
|
||
static uint32_t *map[] = | ||
{ uri, args, html, refresh, memcached, memcached }; | ||
|
||
static uint32_t *map[] = | ||
{ uri, args, uri_component, html, refresh, memcached, memcached }; | ||
|
||
escape = map[type]; | ||
|
||
|
@@ -2317,7 +2336,7 @@ ngx_http_lua_process_args_option(ngx_http_request_t *r, lua_State *L, | |
key = (u_char *) lua_tolstring(L, -2, &key_len); | ||
|
||
key_escape = 2 * ngx_http_lua_escape_uri(NULL, key, key_len, | ||
NGX_ESCAPE_URI); | ||
NGX_ESCAPE_URI_COMPONENT); | ||
total_escape += key_escape; | ||
|
||
switch (lua_type(L, -1)) { | ||
|
@@ -2326,7 +2345,7 @@ ngx_http_lua_process_args_option(ngx_http_request_t *r, lua_State *L, | |
value = (u_char *) lua_tolstring(L, -1, &value_len); | ||
|
||
total_escape += 2 * ngx_http_lua_escape_uri(NULL, value, value_len, | ||
NGX_ESCAPE_URI); | ||
NGX_ESCAPE_URI_COMPONENT); | ||
|
||
len += key_len + value_len + (sizeof("=") - 1); | ||
n++; | ||
|
@@ -2367,7 +2386,7 @@ ngx_http_lua_process_args_option(ngx_http_request_t *r, lua_State *L, | |
total_escape += | ||
2 * ngx_http_lua_escape_uri(NULL, value, | ||
value_len, | ||
NGX_ESCAPE_URI); | ||
NGX_ESCAPE_URI_COMPONENT); | ||
|
||
len += key_len + value_len + (sizeof("=") - 1); | ||
} | ||
|
@@ -2424,7 +2443,7 @@ ngx_http_lua_process_args_option(ngx_http_request_t *r, lua_State *L, | |
|
||
if (total_escape) { | ||
p = (u_char *) ngx_http_lua_escape_uri(p, key, key_len, | ||
NGX_ESCAPE_URI); | ||
NGX_ESCAPE_URI_COMPONENT); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line exceeds 80 columns (so do the following changes from you). Please fix them. Thanks. |
||
|
||
} else { | ||
dd("shortcut: no escape required"); | ||
|
@@ -2438,7 +2457,7 @@ ngx_http_lua_process_args_option(ngx_http_request_t *r, lua_State *L, | |
|
||
if (total_escape) { | ||
p = (u_char *) ngx_http_lua_escape_uri(p, value, value_len, | ||
NGX_ESCAPE_URI); | ||
NGX_ESCAPE_URI_COMPONENT); | ||
|
||
} else { | ||
p = ngx_copy(p, value, value_len); | ||
|
@@ -2457,7 +2476,7 @@ ngx_http_lua_process_args_option(ngx_http_request_t *r, lua_State *L, | |
if (lua_toboolean(L, -1)) { | ||
if (total_escape) { | ||
p = (u_char *) ngx_http_lua_escape_uri(p, key, key_len, | ||
NGX_ESCAPE_URI); | ||
NGX_ESCAPE_URI_COMPONENT); | ||
|
||
} else { | ||
dd("shortcut: no escape required"); | ||
|
@@ -2485,7 +2504,7 @@ ngx_http_lua_process_args_option(ngx_http_request_t *r, lua_State *L, | |
if (total_escape) { | ||
p = (u_char *) ngx_http_lua_escape_uri(p, key, | ||
key_len, | ||
NGX_ESCAPE_URI); | ||
NGX_ESCAPE_URI_COMPONENT); | ||
|
||
} else { | ||
dd("shortcut: no escape required"); | ||
|
@@ -2504,7 +2523,7 @@ ngx_http_lua_process_args_option(ngx_http_request_t *r, lua_State *L, | |
p = (u_char *) | ||
ngx_http_lua_escape_uri(p, key, | ||
key_len, | ||
NGX_ESCAPE_URI); | ||
NGX_ESCAPE_URI_COMPONENT); | ||
|
||
} else { | ||
dd("shortcut: no escape required"); | ||
|
@@ -2520,7 +2539,7 @@ ngx_http_lua_process_args_option(ngx_http_request_t *r, lua_State *L, | |
p = (u_char *) | ||
ngx_http_lua_escape_uri(p, value, | ||
value_len, | ||
NGX_ESCAPE_URI); | ||
NGX_ESCAPE_URI_COMPONENT); | ||
|
||
} else { | ||
p = ngx_copy(p, value, value_len); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the indentation.