-
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
Conversation
src/ngx_http_lua_util.c
Outdated
static uint32_t *map[] = | ||
{ uri, args, html, refresh, memcached, memcached }; | ||
|
||
static uint32_t *map[] = |
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.
@goecho From what I can see. You're escaping not only It's worth mentioning that even Google Chrome's JavaScript API function encodeURIComponent() does not escape all your new candidates:
We needn't be harsher than Google Chrome I think :) |
src/ngx_http_lua_util.c
Outdated
@@ -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 comment
The 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.
@goecho Will you add a simple test case to the existing test case to cover these changes? Thanks! |
…ble with What Google Chrome's JavaScript API function encodeURIComponent() does. see:https://tools.ietf.org/html/rfc2396.
@agentzh I had added a simple test case to the existing test case to cover these changes. 100% compatible with What Google Chrome's JavaScript API function encodeURIComponent() does. see:https://tools.ietf.org/html/rfc2396. >encodeURIComponent(",$@|`")
"%2C%24%40%7C%60"
>encodeURIComponent("-_.!~*'()")
"-_.!~*'()" |
@goecho Cool, thanks. I'll look into this when I have a chance. |
Percent-encode query args when re-attaching them to the `upstream_uri`. Since `ngx.encode_args` does not perform percent-encoding on various reserved characters, this implements a custom `utils.encode_args` function which uses LuaSocket's `url.encode` function. It tries to mimic the `ngx.encode_uri` behaviour 100%. Ideally, `ngx.encode_args` would proceed to the percent-encoding itself (see openresty/lua-nginx-module#542). This also makes some perf and style changes. Fix #749
e7ac10c
to
cfd4f90
Compare
What's the status on this? We still got workarounds in place waiting for this to gets fixed.... |
2 years ago... |
It seems that the same code with function |
OK, I've merged a slightly modified version of this patch. Sorry for the long delay on my side. |
Hello, I using the ngx.escape_uri and ngx.encode_args function doesn't look right. This is RFC 3986 : https://datatracker.ietf.org/doc/html/rfc3986#appendix-A
|
@snpcp according to the rfc you given, the "," should be escaped. |
In the fact, Many software doesn't strictly follow this standard(about gen-delims and sub-delims), And the Openresty look like the same strategy as encodeURIComponent of JavaScript. |
…kipedia.org/wiki/Percent-encoding