Pylons/webob — pull request #83 by rfk (2012-11-09 01:05:49+00:00)
Title: Ignore invalid mime wildcards in MIMEAccept

The current implementation of MIMEAccept will happily parse malformed wildcard strings like "image/pn*" at parse time, but then trigger an AssertionError during matching:

>>> m = MIMEAccept("image/pn*")
>>> m.best_match(["image/png"])
Traceback (most recent call last):
File "", line 1, in
File "webob/acceptparse.py", line 176, in best_match
if self._match(mask, offer):
File "webob/acceptparse.py", line 305, in _match
assert mask.endswith('/*')
AssertionError
>>>

This patch changes MIMEAccept.parse to filter out these invalid values so that client-provided data cannot trigger an assertion.