sanic-org / sanic

Accelerate your web app development | Build fast. Run fast.
https://sanic.dev
MIT License
18.11k stars 1.55k forks source link

fail to search for index in directory with directory name containing CJK characters #3008

Open wh-timme opened 6 days ago

wh-timme commented 6 days ago

Is there an existing issue for this?

Describe the bug

file path: ./public/hello/你好/index.html will return 404 when accessing to http://serving_domain/hello/你好

Code snippet

app.static('/', './public', index='index.html')

Expected Behavior

redirect to ./public/hello/你好/index.html instead of 404 page

How do you run Sanic?

As a script (app.run or Sanic.serve)

Operating System

Linux

Sanic Version

24.6.0

Additional context

No response

adk23333 commented 23 hours ago

Anyway, you shouldn't use chinese path. 不建议使用中文目录,这会出现什么问题,我也不知道。

Tronic commented 20 hours ago

How are CJK pathnames handled nowadays? Unicode or some other weirdness? To my knowledge, Sanic and Python ought to handle Unicode conversions properly, if the browser supplies the path in UTF-8.

To triage, could you print request.url_bytes and request.url, and try if you can open the file with Python open(...), and if so, how do you need to write the CJK characters in that.

adk23333 commented 16 hours ago

How are CJK pathnames handled nowadays? Unicode or some other weirdness? To my knowledge, Sanic and Python ought to handle Unicode conversions properly, if the browser supplies the path in UTF-8.

It is usually URL encoding. example website