Opened 7 years ago
Closed 7 years ago
#29402 closed Bug (needsinfo)
parse_header function in http/multipartparser.py unescapes in wrong order
| Reported by: | Martin Dickopp | Owned by: | nobody |
|---|---|---|---|
| Component: | HTTP handling | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Found by code review: It seems the parse_header function in http/multipartparser.py unescapes values in the wrong order:
value = value.replace(b'\\\\', b'\\').replace(b'\\"', b'"')
If \\ is unescaped before \", the sequence \\" will be unescaped to \" by the first replace function and unescaped again to " by the second replace function. This could be avoided by exchanging the replace functions:
value = value.replace(b'\\"', b'"').replace(b'\\\\', b'\\')
Change History (1)
comment:1 by , 7 years ago
| Component: | Uncategorized → HTTP handling |
|---|---|
| Resolution: | → needsinfo |
| Status: | new → closed |
| Type: | Uncategorized → Bug |
Note:
See TracTickets
for help on using tickets.
That code has been there for 10 years (since d725cc9734272f867d41f7236235c28b3931a1b2). If you find a practical problem with the implementation, please reopen and include a test that demonstrates the issue.