Non-ascii characters in the URL result in malformed data
See original GitHub issueConsider the hello world example:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from bottle import route, run
@route('/hello/<name>')
def index(name='World'):
return '<b>Hello %s!</b>' % name
run(host='localhost', port=8080)
Here, calling the url http://localhost/hello/ŞĞÜ
results in:
Hello ÅÄÃ!
Any ideas?
Issue Analytics
- State:
- Created 11 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to Fix Non-ASCII Characters in a URL - Sitechecker
We'll show you how to fix non-ASCII characters within a URL. Learn more about what characters are valid for URLs.
Read more >How to fix bad decoding without losing other characters?
I have tried to encoding it using ascii with ignore, but I'm losing the pound( £ ) symbol. >>>'10% Off Orders of à ......
Read more >URL Decoding of "malformed" - Online
Decode malformed from URL-encoded format with various advanced options. Our site has an easy to use online tool to convert your data.
Read more >Using URL encoding to handle special characters in a ...
In this article, we will walk through a scenario where exceptions are thrown if such a URI with special character is not handled...
Read more >Wrong codepoints for non-ASCII characters inserted in UTF-8 ...
If operating system and database codepage both are UTF-8, but the data to be inserted is not Unicode, then data in the database...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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. To fix it and keep backward compatibility, maybe you can put a parameter in bottle.run() to tell that the encoding should be UTF-8 and have this parameter set to latin1 by default.
Btw, coffeeowl’s fix does not work for me.
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 And yes, I am using Python3.