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

bottle route URL url encode path #1392

Open
AdamGracery opened this issue Sep 3, 2022 · 6 comments
Open

bottle route URL url encode path #1392

AdamGracery opened this issue Sep 3, 2022 · 6 comments

Comments

@AdamGracery
Copy link

http://localhost:8080/test/我
@get('/test/')
def testme(name):
return 'good'

don't work. but ERROR.

http://localhost:8080/test/hello URL work fine.

I know http://localhost:8080/test?a=我 also work fine.
but I want to know how to make it work. In URL PATH have some unicode words. Wireshark display Its UTF-8 URL Encoded.
http://localhost:8080/test/%E6%88%91

how to set bottle Make it work. Thank YOU!

@Marrin
Copy link

Marrin commented Sep 3, 2022

What do you mean by „http://localhost:8080/test/hello URL work fine“? Not with the @get('/test/') route. That matches /test/ but not /test/anything where it doesn't matter what anything is — even if it is just ASCII.

If you want a route for /test/我 you obviously have to use @get('/test/我').

@AdamGracery
Copy link
Author

i have a mistake.
@get('/test/')
def testme(name):
return 'good'

I mean unicode URL not work. How to work?

@AdamGracery
Copy link
Author

I can't type <> in this post

@AdamGracery
Copy link
Author

i have a mistake.
@get('/test/<name>')
def testme(name):
return 'good'

I mean unicode URL not work. How to work?

@defnull
Copy link
Member

defnull commented Sep 4, 2022

This work fine with both the development version and latest release of bottle and both curl http://localhost:8080/test/我 and curl http://localhost:8080/test/%E6%88%91. Please provide a full example (and use github code formatting or link to a gist or repository to avoid misunderstandings) and also tell us the actual error you get, including the error message and stack trace.

@agalera
Copy link
Contributor

agalera commented Oct 19, 2022

I have tested and it seems to work correctly, try this @AdamGracery :
bottle v0.12.23
python 3.10.4

from bottle import run, get

@get('/test/<name>')
def test(name):
    print(name)
    return name

run()

bottle log

我
127.0.0.1 - - [19/Oct/2022 21:39:26] "GET /test/%E6%88%91 HTTP/1.1" 200 3
我
127.0.0.1 - - [19/Oct/2022 21:39:28] "GET /test/æ HTTP/1.1" 200 3

bash

curl http://localhost:8080/test/%E6%88%91
我%
curl http://localhost:8080/test/我       
我%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants