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)

django13-redirects.patch (1.5 KB ) - added by Alexey Smolsky 13 years ago.
django-redirects-querystring.patch (2.4 KB ) - added by jamey@… 13 years ago.
16842-3.diff (1.7 KB ) - added by Claude Paroz 13 years ago.
Patch updated to current trunk

Download all attachments as: .zip

Change History (10)

comment:1 by Alex Gaynor, 13 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Alexey Smolsky, 13 years ago

Cc: alexey.smolsky@… added
Has patch: set
Needs tests: set

I think kwargs should be applied before concatenation with query string. Patch attached.

Last edited 13 years ago by Alexey Smolsky (previous) (diff)

by Alexey Smolsky, 13 years ago

Attachment: django13-redirects.patch added

comment:3 by jamey@…, 13 years ago

Cc: jamey@… 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 Aymeric Augustin, 13 years ago

Currently, this patch needs tests, which prevents it from being committed.

by jamey@…, 13 years ago

comment:5 by jamey@…, 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?

by Claude Paroz, 13 years ago

Attachment: 16842-3.diff added

Patch updated to current trunk

comment:6 by Claude Paroz, 13 years ago

Needs tests: unset
Triage Stage: AcceptedReady 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.

comment:7 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: newclosed

In [17625]:

Fixed #16842 -- Modified the RedirectView to correctly handle query strings with percent symbols. Thanks, accuser, jamey@… and Claude Paroz.

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