#13260: urlresolvers.reverse() generates invalid URLs when an argument contains
%
character
-----------------------------+-------------------------------------
Reporter: semenov | Owner: aaugustin
Type: Bug | Status: assigned
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+-------------------------------------
Comment (by aaugustin):
I've created a little experiment to showcase the bug:
{{{
# Put this in a file called experiment13260.py and run it with:
# django-admin.py runserver --settings=experiment13260
from django.conf.urls import patterns, url
from django.http import HttpResponse
from django.template import Context, Template
DEBUG = True
ROOT_URLCONF = 'experiment13260'
SECRET_KEY = 'whatever'
TEMPLATE = Template("""<html>
<head>
<title>Experiment with Django ticket #13260</title>
</head>
<body>
<p>Put something with special characters in the URL!</p>
<p>Argument passed to the view: <b>{{ arg }}</b></p>
<p>Reversed URL: <b><a href="{% url 'view' arg %}">{% url 'view' arg
%}</a></b></p>
</body>
</html>""")
urlpatterns = patterns('',
url(r'^(.*)/?$', lambda req, arg:
HttpResponse(TEMPLATE.render(Context({'arg': arg}))), name='view'),
)
}}}
If you go to http://localhost:8000/%252525/, every time you click the
"Reversed URL" link, you lose a 25 in the URL.
--
Ticket URL: <https://code.djangoproject.com/ticket/13260#comment:18>
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.