[Django] #22379: Escaping needed during lazy reversing of non-ascii URLs

14 views
Skip to first unread message

Django

unread,
Apr 3, 2014, 11:07:35 PM4/3/14
to django-...@googlegroups.com
#22379: Escaping needed during lazy reversing of non-ascii URLs
-----------------------------+--------------------
Reporter: jnns | Owner: nobody
Type: Bug | Status: new
Component: Core (URLs) | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------
{{{
# urls.py
url(ur'^umläute_in_der_url/', include('my_app.urls')),
}}}

Reversing the above URL with non-ascii characters returns a properly
percent-encoded string (i.e. 'uml%C3%A4ute_in_der_url').

But a problem occurs while passing the named URL to `reverse_lazy` because
around line 164 in `django.utils.functional.lazy.__mod__` a string
formatting takes place which leads to a ValueError due to the unescaped
percent-encoding.

> ValueError: unsupported format character 'C' (0x43)

{{{
return bytes(self) % rhs
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22379>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 14, 2014, 10:10:19 AM4/14/14
to django-...@googlegroups.com
#22379: Escaping needed during lazy reversing of non-ascii URLs
-----------------------------+--------------------------------------
Reporter: jnns | Owner: nobody
Type: Bug | Status: closed

Component: Core (URLs) | Version: 1.6
Severity: Normal | Resolution: worksforme
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by bmispelon):

* status: new => closed
* needs_docs: => 0
* resolution: => worksforme
* needs_tests: => 0
* needs_better_patch: => 0


Comment:

Hi,

I can't seem to be able to reproduce this:

{{{#!python

# urls.py

...
url(r'^é/$', view=..., name='foo')
...


>>> print(reverse('foo'))
/%C3%A9/
>>> print(reverse_lazy('foo'))
/%C3%A9/
}}}

Can you provide more information as to how you can trigger that error?

Thanks

--
Ticket URL: <https://code.djangoproject.com/ticket/22379#comment:1>

Reply all
Reply to author
Forward
0 new messages