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)
Change History (8)
by , 15 years ago
Attachment: | querydict-copy-encoding-tests.patch added |
---|
by , 15 years ago
Attachment: | querydict-copy-encoding-fix.patch added |
---|
follow-up: 2 comment:1 by , 15 years ago
Component: | Uncategorized → HTTP handling |
---|---|
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 15 years ago
comment:3 by , 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.
by , 15 years ago
Attachment: | querydict-copy-encoding-fix-and-tests.patch added |
---|
comment:4 by , 14 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:5 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
What needs improvement? It appears to be a pretty isolated problem with a simple fix.