Using `UrlHelpers.get_query_string` with `safe` option breaks on unicode values

Issue #4 new
Branko Vukelic created an issue

This is the test case in question:

def test_with_query_params_in_url_unicode(self):
    u = UrlHelper('/foo')
    u.update_query_data(redir='/foo/bar/?q=два+слова')
    print(u.get_query_string())
    print(u.get_query_string(safe='/'))
    self.assertEqual(u.get_query_string(safe='/'),
                     'redir=/foo/bar/%3Fq%3D%D0%B4%D0%B2%D0%B0%2B%D1%81%D0%BB%D0')

Django's implementation of urlencode() doesn't seem to like the unicode stuff when using the safe kwarg. While this is perfectly fine in most cases, it's also desirable to keep the unicode characters as part of the query dict.

For now a documentation patch should notify users of this issue, and we also need to find a solution for this. It's probably not making into v0.1, but I'll look into this for v1.0.

Comments (0)

  1. Log in to comment