question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Non-ascii characters in the URL result in malformed data

See original GitHub issue

Consider 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:closed
  • Created 11 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
blastrockcommented, Nov 26, 2013

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.

0reactions
coffeeowlcommented, Feb 24, 2013

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found