Opened 15 years ago

Closed 14 years ago

#13572 closed (fixed)

QueryDict.copy().encoding is not set correctly

Reported by: adammck Owned by: nobody
Component: HTTP handling Version: dev
Severity: Keywords: querydict, mutable, copy, encoding
Cc: 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

When QueryDict.copy() is called, a new (mutable) querydict is returned, but its 'encoding' attr is not set. This results in the copy being re-encoded wrongly. For example, this works correctly:

>>> q = QueryDict('foo=bar', encoding='rot_13')
>>> q.encoding, q.urlencode()
('foo=bar', 'rot_13')

But this is clearly wrong:

>>> q = QueryDict('foo=bar', encoding='rot_13').copy()
>>> q.encoding, q.urlencode()
('sbb=one', 'utf-8')

Oops! Patch attached, and regression tests which better illustrate the problem.

Attachments (3)

querydict-copy-encoding-tests.patch (891 bytes ) - added by adammck 15 years ago.
querydict-copy-encoding-fix.patch (910 bytes ) - added by adammck 15 years ago.
querydict-copy-encoding-fix-and-tests.patch (1.8 KB ) - added by adammck 15 years ago.

Download all attachments as: .zip

Change History (8)

by adammck, 15 years ago

comment:1 by Alex Gaynor, 15 years ago

Component: UncategorizedHTTP handling
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

in reply to:  1 comment:2 by adammck, 15 years ago

What needs improvement? It appears to be a pretty isolated problem with a simple fix.

comment:3 by Alex Gaynor, 15 years ago

Patch needs improvement: unset

Bah, I didn't notice that there were 2 patches, one with tests and the other with a patch. Can you combine those into a single diff.

comment:4 by Alex Gaynor, 15 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by Jacob, 14 years ago

Resolution: fixed
Status: newclosed

(In [13314]) Fixed #13572: copies of QueryDicts now have their encoding set correctly.

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