-
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
ngx.escape_uri should escape RFC 3986 section 2.2 Reserved Characters #1124
Comments
@hunterli Will you contribute a pull request for it? Thanks! |
@agentzh OK, I'll try it. |
@hunterli Great! Looking forward to it! |
ngx.escape_uri should also escape RFC 3986 section 2.2 Reserved Characters. Signed-off-by: Yichun Zhang (agentzh) <[email protected]>
I am afraid I don't think it is a bug. According to the document,
Although its name is Escape uri is different from escaping URI component.
Note that the RFC only requires the gen-delims part of reserved characters. Not all the reserved characters. What
Don't mix up these two differnt things. |
@spacewander |
@hunterli |
One place I found including
However, it just says According to |
@spacewander I test url encode function in php and lua, both of them output %27. So may be compatible with other programming language to escape
|
Why not be compatible with Javascript? It doesn't escape Another option is do what Go developers did: they just simply said:
Luckily, our previous implementation is more compatible with If your target environment requires special encode rule, just do it in your code. |
…penresty#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.
…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) <[email protected]>
@spacewander I "Try Go" in https://golang.org: package main import( func main() { output:%27 |
@spacewander In RFC 3986 2.2 Reserved Characters:
For "&" and "'" both in sub-delims, ngx.escape_uri encode "&", why not "'"? |
|
被你弄糊涂了,Sorry,中文直接上了,看不懂就放弃了。也可能是我理解错误,RFC说"Reserved Characters"都应该escape,"Reserved Characters"包含gen-delims和sub-delims,这样的话gen-delims和sub-delims都应该escape,否则就是"白马非马"了。 |
Could you point out where RFC 3986 says that all reserved characters should be escaped for URI component? |
这个是什么意思呀?通常的用户不是这样用么: Appendix A. 里面说:
那么"&","="都不应该escape?能这样理解么? |
$ python -c "import urllib; print urllib.quote(\"'\")"
%27
$ resty -e "ngx.say(ngx.escape_uri(\"'\"))"
'
ngx.escape_uri should escape "'" to %27 but not.
$resty -v
resty 0.17
nginx version: openresty/1.11.2.3
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
built with OpenSSL 1.0.2k 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.0 --add-module=../echo-nginx-module-0.60 --add-module=../xss-nginx-module-0.05 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.31 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.06 --add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.8 --add-module=../ngx_lua_upstream-0.06 --add-module=../headers-more-nginx-module-0.32 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.18 --add-module=../redis2-nginx-module-0.14 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.14 --add-module=../rds-csv-nginx-module-0.07 --with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib --with-openssl=/tmp/openssl-1.0.2k --with-pcre=/tmp/pcre-8.39 --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-ipv6 --with-mail --with-mail_ssl_module --with-md5-asm --with-pcre-jit --with-sha1-asm --with-stream --with-stream_ssl_module --with-threads
The text was updated successfully, but these errors were encountered: