summaryrefslogtreecommitdiffstats
path: root/Lib/cgi.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-06-17 13:36:20 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-06-17 13:36:20 (GMT)
commit774bed7e6098358012bd4ea05914497891ab4652 (patch)
treec0568ec0bf0c5b7c9bc08d5495e96e262cbadb93 /Lib/cgi.py
parent78be6e8aa3a0fec844bbc1af13b63826808f1f72 (diff)
parentc7bfe0e42eb72d941a8a131e870aefabd4547015 (diff)
downloadcpython-774bed7e6098358012bd4ea05914497891ab4652.zip
cpython-774bed7e6098358012bd4ea05914497891ab4652.tar.gz
cpython-774bed7e6098358012bd4ea05914497891ab4652.tar.bz2
Issue #18167: cgi.FieldStorage no more fails to handle multipart/form-data
when \r\n appears at end of 65535 bytes without other newlines.
Diffstat (limited to 'Lib/cgi.py')
-rwxr-xr-xLib/cgi.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/cgi.py b/Lib/cgi.py
index 385a57c..e3cf33e 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -786,6 +786,9 @@ class FieldStorage:
if not line:
self.done = -1
break
+ if delim == b"\r":
+ line = delim + line
+ delim = b""
if line.startswith(b"--") and last_line_lfend:
strippedline = line.rstrip()
if strippedline == next_boundary:
@@ -802,6 +805,12 @@ class FieldStorage:
delim = b"\n"
line = line[:-1]
last_line_lfend = True
+ elif line.endswith(b"\r"):
+ # We may interrupt \r\n sequences if they span the 2**16
+ # byte boundary
+ delim = b"\r"
+ line = line[:-1]
+ last_line_lfend = False
else:
delim = b""
last_line_lfend = False