summaryrefslogtreecommitdiff
path: root/Lib/cgi.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-07-23 17:27:05 +0000
committerGuido van Rossum <guido@python.org>1996-07-23 17:27:05 +0000
commit99aa2a413258895725e0fe96a2ac182a024318f8 (patch)
tree9d7395782743b1d42febf4208e5aaf590ee9259f /Lib/cgi.py
parent71e315b9d90aca5b5b74ca6cf78abf6f7be744b7 (diff)
downloadcpython-git-99aa2a413258895725e0fe96a2ac182a024318f8.tar.gz
Remove all CRLF -> LF translation for file uploads, since we cannot
reliably distinguish binary files from text files (and Mac Netscape sends all files in "binary" form, i.e. it sends text files with only CR delimiters...).
Diffstat (limited to 'Lib/cgi.py')
-rwxr-xr-xLib/cgi.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/Lib/cgi.py b/Lib/cgi.py
index 77e76b6306..15af21742c 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -397,7 +397,7 @@ backwards compatible and debugging classes and functions?
"""
-__version__ = "2.0b1"
+__version__ = "2.0b2"
# Imports
@@ -540,16 +540,20 @@ def parse_multipart(fp, pdict):
terminator = string.strip(line)
if terminator in (nextpart, lastpart):
break
- if line[-2:] == '\r\n':
- line = line[:-2]
- elif line[-1:] == '\n':
- line = line[:-1]
lines.append(line)
# Done with part.
if data is None:
continue
if bytes < 0:
- data = string.joinfields(lines, "\n")
+ if lines:
+ # Strip final line terminator
+ line = lines[-1]
+ if line[-2:] == "\r\n":
+ line = line[:-2]
+ elif line[-1:] == "\n":
+ line = line[:-1]
+ lines[-1] = line
+ data = string.joinfields(lines, "")
line = headers['content-disposition']
if not line:
continue
@@ -859,8 +863,6 @@ class FieldStorage:
self.done = -1
break
self.lines.append(line)
- if line[-2:] == '\r\n':
- line = line[:-2] + '\n'
self.file.write(line)
def read_lines_to_outerboundary(self):
@@ -882,11 +884,14 @@ class FieldStorage:
self.done = 1
break
if line[-2:] == "\r\n":
+ delim = "\r\n"
line = line[:-2]
elif line[-1] == "\n":
+ delim = "\n"
line = line[:-1]
+ else:
+ delim = ""
self.file.write(delim + line)
- delim = "\n"
def skip_lines(self):
"""Internal: skip lines until outer boundary if defined."""