enforce a maximum header line length
This commit is contained in:
parent
3769ddebc6
commit
0b79cd174f
11
av98.py
11
av98.py
|
@ -334,9 +334,14 @@ you'll be able to transparently follow links to Gopherspace!""")
|
||||||
address, f = None, open(gi.path, "rb")
|
address, f = None, open(gi.path, "rb")
|
||||||
else:
|
else:
|
||||||
address, f = self._send_request(gi)
|
address, f = self._send_request(gi)
|
||||||
# Read response header
|
|
||||||
header = f.readline()
|
# Spec dictates <META> should not exceed 1024 bytes
|
||||||
header = header.decode("UTF-8").strip()
|
# but does not dictate a total maximum header length.
|
||||||
|
header = f.readline(2048)
|
||||||
|
header = header.decode("UTF-8")
|
||||||
|
if header[-1] != '\n':
|
||||||
|
raise RuntimeError("Received invalid header from server!")
|
||||||
|
header = header.strip()
|
||||||
self._debug("Response header: %s." % header)
|
self._debug("Response header: %s." % header)
|
||||||
|
|
||||||
# Catch network errors which may happen on initial connection
|
# Catch network errors which may happen on initial connection
|
||||||
|
|
Loading…
Reference in New Issue