Skip to content
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

request help: url contains Chinese, will decode utf8 encoded url into hexadecimal format of \x #7838

Closed
biubiue opened this issue Sep 1, 2022 · 8 comments
Labels
no response wait for update wait for the author's response in this issue/PR

Comments

@biubiue
Copy link
Contributor

biubiue commented Sep 1, 2022

Current Behavior

raw url: https://xxx.com/a/中文.html
url will encode this: https://xxx.com/a/%E4%B8%AD%E6%96%87.html
fact in apisix: https://xxx.com/a/\xE4\xB8\xAD\xE6\x96\x87.html

Expected Behavior

No response

Error Logs

No response

Steps to Reproduce

raw url: https://xxx.com/a/中文.html
url will encode this: https://xxx.com/a/%E4%B8%AD%E6%96%87.html
fact in apisix: https://xxx.com/a/\xE4\xB8\xAD\xE6\x96\x87.html

Environment

  • APISIX version (run apisix version):2.15
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):
@monkeyDluffy6017
Copy link
Contributor

monkeyDluffy6017 commented Sep 9, 2022

curl "http://127.0.0.1:9080/apisix/admin/routes/1" -H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1" -X PUT -d '
{
  "methods": ["GET"],
  "host": "example.com",
  "uri": "/中文/*",
  "upstream": {
    "type": "roundrobin",
    "nodes": {
      "httpbin.org:80": 1
    }
  }
}'

curl -i -X GET "http://127.0.0.1:9080/中文/foo?arg=10" -H "Host: [example.com](http://example.com/)
curl -i -X GET "http://127.0.0.1:9080/%E4%B8%AD%E6%96%87/foo?arg=10" -H "Host: [example.com](http://example.com/)"

I test with the above test case, and both successfully match the route.
Could you tell me how i reproduce the problem?

@biubiue
Copy link
Contributor Author

biubiue commented Sep 9, 2022

curl "http://127.0.0.1:9080/apisix/admin/routes/1" -H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1" -X PUT -d '
{
  "methods": ["GET"],
  "host": "example.com",
  "uri": "/中文/*",
  "upstream": {
    "type": "roundrobin",
    "nodes": {
      "httpbin.org:80": 1
    }
  }
}'

curl -i -X GET "http://127.0.0.1:9080/中文/foo?arg=10" -H "Host: [example.com](http://example.com/)
curl -i -X GET "http://127.0.0.1:9080/%E4%B8%AD%E6%96%87/foo?arg=10" -H "Host: [example.com](http://example.com/)"

I test with the above test case, and both successfully match the route. Could you tell me how i reproduce the problem?

Em... Match route is ok. I want to say , when url contains Chinese ,upstream will recevie hex ,like this \xE4\xB8\xAD\xE6\x96\x87

@monkeyDluffy6017
Copy link
Contributor

monkeyDluffy6017 commented Sep 9, 2022

#7401
Does this feature will help?

@biubiue
Copy link
Contributor Author

biubiue commented Sep 9, 2022

#7401 Does this feature will help?

I set proxy-rewrite.use_real_request_uri_unsafe=true in global by Apisix dashboard, not work

@monkeyDluffy6017
Copy link
Contributor

request APISIX

curl -i -X GET "http://127.0.0.1:9080/%25E4%25B8%25AD%25E6%2596%2587/foo?arg=10"
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Transfer-Encoding: chunked
Connection: keep-alive
Date: Fri, 09 Sep 2022 08:37:46 GMT
Server: APISIX/2.15.0   

upstream nginx log:

==> logs/access.log <==
127.0.0.1 - - [09/Sep/2022:16:37:46 +0800] "GET /%25E4%25B8%25AD%25E6%2596%2587/foo?arg=10 HTTP/1.1" 200 35 "-" "curl/7.58.0"

APISIX will not change your URL, it just forward your URL if you don't use any plugin.

So where is the problem?

Many web server, like nginx, it will decode the url-encoded URL before match the route.

So I guess you could encoded your URL twice like the example above.

@tzssangglass tzssangglass changed the title bug: url contains Chinese, will decode utf8 encoded url into hexadecimal format of \x request help: url contains Chinese, will decode utf8 encoded url into hexadecimal format of \x Sep 13, 2022
@shreemaan-abhishek
Copy link
Contributor

@biubiue any updates? If not, please close this issue. Thanks.

@shreemaan-abhishek shreemaan-abhishek added the wait for update wait for the author's response in this issue/PR label Sep 6, 2023
@github-actions
Copy link

Due to lack of the reporter's response this issue has been labeled with "no response". It will be close in 3 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.

@github-actions
Copy link

This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no response wait for update wait for the author's response in this issue/PR
Projects
None yet
Development

No branches or pull requests

3 participants