recently I started to see exceptions in mimeparse.best_match.
The user agent submits an HTTP_ACCEPT header like that one:
'text/html,application/xhtml+xml,application/xml;image/png,image/jpeg,image/*;q=0.9,*/*;q=0.8')
Here's my traceback:
File "…/Paste-1.7.4-py2.7.egg/paste/util/mimeparse.py", line 119, in best_match
parsed_header = [parse_media_range(r) for r in header.split(",")]
File "…/Paste-1.7.4-py2.7.egg/paste/util/mimeparse.py", line 54, in
parse_media_range
(type, subtype, params) = parse_mime_type(range)
File "…/Paste-1.7.4-py2.7.egg/paste/util/mimeparse.py", line 33, in
parse_mime_type
for param in parts[1:] ])
ValueError: dictionary update sequence element #0 has length 1; 2 is required
First I'm not sure if the header is invalid at all. Assuming it is, should
best_match raise an exception for invalid input formats? Are there paste
methods which don't raise exceptions (as user agents can submit arbitrary
strings in http headers)?
fs