Nginx URI参数%xx字符解码
对URI参数值中的%XX
这样的编码序列进行解码,可以使用第三方 ngx_set_misc
模块提供的 set_unescape_uri
指令:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| location /decode { set_unescape_uri $name $arg_name; set_unescape_uri $class $arg_class;
echo "name: $name"; echo "class: $class"; }
location /test { echo "name: $arg_name"; echo "class: $arg_class"; }
$ curl 'http://localhost/test?name=hello%20xiemx&class=1' name: hello%20xiemx class: 1
$ curl 'http://localhost/decode?name=hello%20xiemx&class=1' name: hello xiemx class: 1
|