#20022: reverse() breaks on URLs which include a ~ character
-------------------------------+--------------------
Reporter: mxheyeck@… | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.5
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Testing on my local machine through Apache, so the root URL is at:
http://localhost/~mxheyeck/sicariid/
Calling reverse on one of my views inside views.py, e.g.:
s = reverse(locate_task_enter, args=(task_id,))
Breaks with the cryptic message:
"a float is required"
A little examination reveals what's going on. Break is at line 391 of
urlresolvers.py.
candidate = (prefix_norm + result) % dict(zip(prefix_args + params,
unicode_args))
prefix_norm is:
u'/%7Emxheyeck/sicariid/'
So line 391 is equivalent to:
u'/%7Emxheyeck/sicariid/locate_task_enter/%(task_id)s/' % {u'task_id':
u'419'}
Where '%7E' is both a urlencoded tilde and, unfortunately, an upper-case
floating-point exponential. So, boom.
I attach the local vars from the break at 391.
{{{
val 419L
pattern 'locate_task_enter/(?P<task_id>\\d+)/$'
self <RegexURLResolver 'sitespecific.urls' (None:None) ^/>
args (419L,)
_prefix u'/~mxheyeck/sicariid/'
possibility [(u'locate_task_enter/%(task_id)s/', [u'task_id'])]
unicode_args [u'419']
possibilities [([(u'locate_task_enter/%(task_id)s/', [u'task_id'])],
'locate_task_enter/(?P<task_id>\\d+)/$', {})]
lookup_view <function locate_task_enter at 0x1065f8668>
prefix_norm u'/%7Emxheyeck/sicariid/'
prefix_args []
params [u'task_id']
result u'locate_task_enter/%(task_id)s/'
defaults {}
kwargs {}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20022>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.