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 Tim Graham, 7 years ago

Component: UncategorizedHTTP handling
Resolution: needsinfo
Status: newclosed
Type: UncategorizedBug

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.

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