-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Non-ascii characters in the URL result in malformed data #371
Comments
It works fine here, maybe it is just your browser with wrong encoding. |
I've tested with Firefox and Chrome (on Linux and Windows) and it gave me garbled text. What's your environment? |
Found a fix! Encoding the string in latin-1 and then decoding in utf-8 works. Why is this necessary?
|
Because WSGI 3333 (the Python3 WSGI standard) requires all incoming data to be latin1-encoded unicode and a framework has no way to guess the correct encoding. Bottle assumes utf-8 in many places already, though. This should be cleaned up in a future release (it breaks backward compatibility, so it's not that easy) |
I guess I have the same problem. I am writing a webapp and unfortunately some URLs might contain non-latin characters. As a result I get a garbage instead of normal URL parameters and can query a DB with them. I am not sure what are the consequences of my hack, but it was easy to fix, I have changed the encoding to utf-8 on this line - https://github.com/defnull/bottle/blob/master/bottle.py#L82 |
I had this same bug, it took me a while to understand what was going on. I couldn't find anywhere in the documentation where this is mentioned, please someone document it and include that encode("latin1") trick until you fix it. Btw, coffeeowl's fix does not work for me. |
Consider the hello world example:
Here, calling the url
http://localhost/hello/ŞĞÜ
results in:Any ideas?
The text was updated successfully, but these errors were encountered: