mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
statusandheaders parsing: properly skip multiline bad headers (missing
header name and ':'), fixes #49
This commit is contained in:
parent
e4bcef1c8b
commit
00121aa165
@ -169,7 +169,8 @@ class StatusAndHeadersParser(object):
|
||||
|
||||
# append continuation lines, if any
|
||||
while next_line and next_line.startswith((' ', '\t')):
|
||||
value += next_line
|
||||
if value is not None:
|
||||
value += next_line
|
||||
next_line, total_read = _strip_count(stream.readline(),
|
||||
total_read)
|
||||
|
||||
|
@ -32,6 +32,10 @@ False
|
||||
# empty
|
||||
>>> st2 = StatusAndHeadersParser(['HTTP/1.0']).parse(BytesIO(status_headers_2)); x = st2.validate_statusline('204 No Content'); st2
|
||||
StatusAndHeaders(protocol = '', statusline = '204 No Content', headers = [])
|
||||
|
||||
|
||||
>>> StatusAndHeadersParser(['HTTP/1.0']).parse(BytesIO(status_headers_3))
|
||||
StatusAndHeaders(protocol = 'HTTP/1.0', statusline = '204 Empty', headers = [('Content-Type', 'Value'), ('Content-Length', '0')])
|
||||
"""
|
||||
|
||||
|
||||
@ -54,6 +58,14 @@ status_headers_2 = """
|
||||
|
||||
"""
|
||||
|
||||
status_headers_3 = "\
|
||||
HTTP/1.0 204 Empty\r\n\
|
||||
Content-Type: Value\r\n\
|
||||
%Invalid%\r\n\
|
||||
\tMultiline\r\n\
|
||||
Content-Length: 0\r\n\
|
||||
\r\n"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import doctest
|
||||
|
Loading…
x
Reference in New Issue
Block a user