Opened 10 years ago

Closed 10 years ago

#22379 closed Bug (worksforme)

Escaping needed during lazy reversing of non-ascii URLs

Reported by: Jannis Vajen 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

Description

# 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

Change History (1)

comment:1 by Baptiste Mispelon, 10 years ago

Resolution: worksforme
Status: newclosed

Hi,

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

# 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

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