New submission from Ben Darnell <[email protected]>:
cgi.parse_header doesn't work on headers that contain combinations of double
quotes and semicolons (although it works with either type of character
individually).
>>> cgi.parse_header('form-data; name="files"; filename="fo\\"o;bar"')
('form-data', {'name': 'files', 'filename': '"fo\\"o'})
This issue is present in python 2.7 and 3.2. One solution is to change
_parseparam as follows (same as email.message._parseparam):
def _parseparam(s):
while s[:1] == ';':
s = s[1:]
end = s.find(';')
while end > 0 and (s.count('"', 0, end) - s.count('\\"', 0, end)) % 2:
end = s.find(';', end + 1)
if end < 0:
end = len(s)
f = s[:end]
yield f.strip()
s = s[end:]
----------
messages: 140091
nosy: Ben.Darnell
priority: normal
severity: normal
status: open
title: cgi.parse_header fails on double quotes and semicolons
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue12529>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com