| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -786,6 +786,9 @@ def read_lines_to_outerboundary(self): | |||
| 786 | 786 | if not line: | |
| 787 | 787 | self.done = -1 | |
| 788 | 788 | break | |
| 789 | + if delim == b"\r": | ||
| 790 | + line = delim + line | ||
| 791 | + delim = b"" | ||
| 789 | 792 | if line.startswith(b"--") and last_line_lfend: | |
| 790 | 793 | strippedline = line.rstrip() | |
| 791 | 794 | if strippedline == next_boundary: | |
@@ -802,6 +805,12 @@ def read_lines_to_outerboundary(self): | |||
| 802 | 805 | delim = b"\n" | |
| 803 | 806 | line = line[:-1] | |
| 804 | 807 | last_line_lfend = True | |
| 808 | + elif line.endswith(b"\r"): | ||
| 809 | + # We may interrupt \r\n sequences if they span the 2**16 | ||
| 810 | + # byte boundary | ||
| 811 | + delim = b"\r" | ||
| 812 | + line = line[:-1] | ||
| 813 | + last_line_lfend = False | ||
| 805 | 814 | else: | |
| 806 | 815 | delim = b"" | |
| 807 | 816 | last_line_lfend = False | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -256,6 +256,29 @@ def test_fieldstorage_multipart_non_ascii(self): | |||
| 256 | 256 | got = getattr(fs.list[x], k) | |
| 257 | 257 | self.assertEqual(got, exp) | |
| 258 | 258 | ||
| 259 | + def test_fieldstorage_multipart_maxline(self): | ||
| 260 | + # Issue #18167 | ||
| 261 | + maxline = 1 << 16 | ||
| 262 | + self.maxDiff = None | ||
| 263 | + def check(content): | ||
| 264 | + data = """---123 | ||
| 265 | + Content-Disposition: form-data; name="upload"; filename="fake.txt" | ||
| 266 | + Content-Type: text/plain | ||
| 267 | + | ||
| 268 | + %s | ||
| 269 | + ---123-- | ||
| 270 | + """.replace('\n', '\r\n') % content | ||
| 271 | + environ = { | ||
| 272 | + 'CONTENT_LENGTH': str(len(data)), | ||
| 273 | + 'CONTENT_TYPE': 'multipart/form-data; boundary=-123', | ||
| 274 | + 'REQUEST_METHOD': 'POST', | ||
| 275 | + } | ||
| 276 | + self.assertEqual(gen_result(data, environ), | ||
| 277 | + {'upload': content.encode('latin1')}) | ||
| 278 | + check('x' * (maxline - 1)) | ||
| 279 | + check('x' * (maxline - 1) + '\r') | ||
| 280 | + check('x' * (maxline - 1) + '\r' + 'y' * (maxline - 1)) | ||
| 281 | + | ||
| 259 | 282 | _qs_result = { | |
| 260 | 283 | 'key1': 'value1', | |
| 261 | 284 | 'key2': ['value2x', 'value2y'], | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -123,6 +123,9 @@ Core and Builtins | |||
| 123 | 123 | Library | |
| 124 | 124 | ------- | |
| 125 | 125 | ||
| 126 | + - Issue #18167: cgi.FieldStorage no more fails to handle multipart/form-data | ||
| 127 | + when \r\n appears at end of 65535 bytes without other newlines. | ||
| 128 | + | ||
| 126 | 129 | - Issue #18076: Introduce importlib.util.decode_source(). | |
| 127 | 130 | ||
| 128 | 131 | - importlib.abc.SourceLoader.get_source() no longer changes SyntaxError or | |
| Back | FazBrowse Home | New Git URL |
0 commit comments