Update content-disposition parsing workaround
Also adds workaround for https://github.com/python/cpython/issues/93010
This commit is contained in:
parent
14bcdc86a2
commit
9afcad1224
|
|
@ -89,13 +89,16 @@ class ContentDisposition:
|
|||
try:
|
||||
parsed = reg('Content-Disposition', decoded)
|
||||
except IndexError: # pragma: no cover
|
||||
# WORKAROUND for https://bugs.python.org/issue37491
|
||||
# WORKAROUND for https://github.com/python/cpython/issues/81672
|
||||
# Fixed in Python 3.7.5 and 3.8.0.
|
||||
# Still getting failures on 3.10 on CI though
|
||||
raise ContentDispositionError("Missing closing quote character")
|
||||
except ValueError: # pragma: no cover
|
||||
# WORKAROUND for https://bugs.python.org/issue42946
|
||||
# WORKAROUND for https://github.com/python/cpython/issues/87112
|
||||
raise ContentDispositionError("Non-ASCII digit")
|
||||
except AttributeError:
|
||||
# WORKAROUND for https://github.com/python/cpython/issues/93010
|
||||
raise ContentDispositionError("Section number has an invalid leading 0")
|
||||
|
||||
if parsed.defects:
|
||||
defects = list(parsed.defects)
|
||||
|
|
|
|||
|
|
@ -44,6 +44,21 @@ def test_no_content_disposition(stubs, url, expected):
|
|||
assert filename == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize('value', [
|
||||
# https://github.com/python/cpython/issues/87112
|
||||
'inline; 0*²'.encode("iso-8859-1"),
|
||||
# https://github.com/python/cpython/issues/81672
|
||||
b'"',
|
||||
# https://github.com/python/cpython/issues/93010
|
||||
b'attachment; 0*00="foo"',
|
||||
# FIXME: Should probably have more tests if this is still relevant after
|
||||
# dropping QtWebKit.
|
||||
])
|
||||
def test_parse_content_disposition_invalid(value):
|
||||
with pytest.raises(http.ContentDispositionError):
|
||||
http.ContentDisposition.parse(value)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('template', [
|
||||
'{}',
|
||||
'attachment; filename="{}"',
|
||||
|
|
|
|||
Loading…
Reference in New Issue