Opened 13 years ago
Closed 13 years ago
#16842 closed Bug (fixed)
RedirectView (class based) query string format bug
Reported by: | Sławek Ehlert | Owned by: | nobody |
---|---|---|---|
Component: | Generic views | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | alexey.smolsky@…, jamey@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
There is a problem with the new class based RedirectView with query_string = True and some unicode string in QUERY_STRING.
I made a sample of the error on bitbucket
https://bitbucket.org/slafs/redirectviewtest/src
The error that I'm getting is :
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in get_redirect_url 146. return url % kwargs Exception Type: ValueError at /test/ Exception Value: unsupported format character 'C' (0x43) at index 15
Basically the problem is when a QUERY_STRING contains some unicode chars that were previously encoded with urlencode (i.e. {{ request.GET.urlencode }} - like in my bitbucket example ) and for example polish "ż" is encoded as "%C5" which breaks the "%" formatting.
The relevant topic on Google Groups is here https://groups.google.com/d/topic/django-users/L0hkxuyUt4U/discussion
As Karen M. Tracey suggested I opened this ticket.
Attachments (3)
Change History (10)
comment:1 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 13 years ago
Cc: | added |
---|---|
Has patch: | set |
Needs tests: | set |
by , 13 years ago
Attachment: | django13-redirects.patch added |
---|
comment:3 by , 13 years ago
Cc: | added |
---|
I believe accuser's patch is the correct fix for this bug, which I just ran into. I hope it will be included in 1.4, though I'd also like a stable release on the 1.3 series to include this patch and the fix for #15852.
comment:4 by , 13 years ago
Currently, this patch needs tests, which prevents it from being committed.
by , 13 years ago
Attachment: | django-redirects-querystring.patch added |
---|
comment:5 by , 13 years ago
OK, I've added a test case to accuser's patch, which fails without the patch and passes with it. Good enough?
comment:6 by , 13 years ago
Needs tests: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
The patch could not be applied to trunk. The part about the function-based generic view "redirect_to" has been fixed in r17034. Just uploaded a new patch with that part removed.
I think kwargs should be applied before concatenation with query string. Patch attached.