Opened 4 years ago

Closed 4 years ago

#22379 closed Bug (worksforme)

Escaping needed during lazy reversing of non-ascii URLs

Reported by: Jannis Owned by: nobody
Component: Core (URLs) Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


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

Change History (1)

comment:1 Changed 4 years ago by Baptiste Mispelon

Resolution: worksforme
Status: newclosed


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


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

>>> print(reverse('foo'))
>>> print(reverse_lazy('foo'))

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


Note: See TracTickets for help on using tickets.
Back to Top