Kaydet (Commit) 99aa2a41 authored tarafından Guido van Rossum's avatar Guido van Rossum

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...).
üst 71e315b9
...@@ -397,7 +397,7 @@ backwards compatible and debugging classes and functions? ...@@ -397,7 +397,7 @@ backwards compatible and debugging classes and functions?
""" """
__version__ = "2.0b1" __version__ = "2.0b2"
# Imports # Imports
...@@ -540,16 +540,20 @@ def parse_multipart(fp, pdict): ...@@ -540,16 +540,20 @@ def parse_multipart(fp, pdict):
terminator = string.strip(line) terminator = string.strip(line)
if terminator in (nextpart, lastpart): if terminator in (nextpart, lastpart):
break break
if line[-2:] == '\r\n':
line = line[:-2]
elif line[-1:] == '\n':
line = line[:-1]
lines.append(line) lines.append(line)
# Done with part. # Done with part.
if data is None: if data is None:
continue continue
if bytes < 0: 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'] line = headers['content-disposition']
if not line: if not line:
continue continue
...@@ -859,8 +863,6 @@ class FieldStorage: ...@@ -859,8 +863,6 @@ class FieldStorage:
self.done = -1 self.done = -1
break break
self.lines.append(line) self.lines.append(line)
if line[-2:] == '\r\n':
line = line[:-2] + '\n'
self.file.write(line) self.file.write(line)
def read_lines_to_outerboundary(self): def read_lines_to_outerboundary(self):
...@@ -882,11 +884,14 @@ class FieldStorage: ...@@ -882,11 +884,14 @@ class FieldStorage:
self.done = 1 self.done = 1
break break
if line[-2:] == "\r\n": if line[-2:] == "\r\n":
delim = "\r\n"
line = line[:-2] line = line[:-2]
elif line[-1] == "\n": elif line[-1] == "\n":
delim = "\n"
line = line[:-1] line = line[:-1]
else:
delim = ""
self.file.write(delim + line) self.file.write(delim + line)
delim = "\n"
def skip_lines(self): def skip_lines(self):
"""Internal: skip lines until outer boundary if defined.""" """Internal: skip lines until outer boundary if defined."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment