#22589: url reverse should encode forward slashes
-------------------------------+--------------------
Reporter: denilsonsa | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
I have essentially the same issue as this guy:
http://stackoverflow.com/questions/4241484/use-djangos-url-template-tag-
with-special-characters
{{{
# In urls.py:
url(r'^something/(?P<title>[^/]*)/something/else$', views.something,
name='something'),
# In a template:
<a href="{% url something page.title %}">Some link</a>
}}}
Here, `page.title` is a completely free-form string that might contain any
characters, including forward slashes. I want to encode it completely. The
current url `reverse()` code will quote any parameters using Django's
`urlquote`, which will call Python's `quote`, which will encode all
special characters, except the slash (and `_.-`).
https://github.com/django/django/blob/91afc00513bd2fa6302ea2be35e1f842cbd5fd38/django/core/urlresolvers.py#L459
There is no hook or option to make url reverse encode the slash while
building the URL. We can't pre-encode the slash either, as it will lead to
double-encoding the slashes (requiring an extra decoding step inside the
view). So, there is no straightforward way to build a URL while encoding
the slashes from args.
My suggestion is to change the behavior of url reverse to also encode
forward slashes. Or, at least, give some flexibility when encoding the
URL.
--
Ticket URL: <https://code.djangoproject.com/ticket/22589>
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/053.20f1d38499e1f7af80efc72a8875b556%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.