diff -ur Python-3.1.2/Lib/cgi.py Python-3.1.2-fix-cgi/Lib/cgi.py --- Python-3.1.2/Lib/cgi.py 2009年05月08日 05:57:12.000000000 +0200 +++ Python-3.1.2-fix-cgi/Lib/cgi.py 2010年05月28日 22:33:12.000000000 +0200 @@ -613,7 +613,9 @@ # Get subparts msgs = full_msg.get_payload() for msg in msgs: - fp = StringIO(msg.get_payload()) + payload = msg.get_payload() + fp = StringIO(payload) + msg['content-length'] = len(payload) part = klass(fp, msg, ib, environ, keep_blank_values, strict_parsing) self.list.append(part) diff -ur Python-3.1.2/Lib/email/feedparser.py Python-3.1.2-fix-cgi/Lib/email/feedparser.py --- Python-3.1.2/Lib/email/feedparser.py 2007年10月16日 20:12:55.000000000 +0200 +++ Python-3.1.2-fix-cgi/Lib/email/feedparser.py 2010年05月28日 22:34:28.000000000 +0200 @@ -28,7 +28,7 @@ NLCRE = re.compile('\r\n|\r|\n') NLCRE_bol = re.compile('(\r\n|\r|\n)') -NLCRE_eol = re.compile('(\r\n|\r|\n)$') +NLCRE_eol = re.compile('(\r\n|\r|\n)\Z') NLCRE_crack = re.compile('(\r\n|\r|\n)') # RFC 2822 3ドル.6.8 Optional fields. ftext is %d33-57 / %d59-126, Any character # except controls, SP, and ":". diff -ur Python-3.1.2/Lib/test/test_cgi.py Python-3.1.2-fix-cgi/Lib/test/test_cgi.py --- Python-3.1.2/Lib/test/test_cgi.py 2009年08月13日 10:51:18.000000000 +0200 +++ Python-3.1.2-fix-cgi/Lib/test/test_cgi.py 2010年05月28日 22:24:50.000000000 +0200 @@ -211,8 +211,22 @@ Content-Disposition: form-data; name="file"; filename="test.txt" Content-Type: text/plain -Testing 123. +Testing 123.\n +-----------------------------721837373350705526688164684 +Content-Disposition: form-data; name="file2"; filename="test2.txt" +Content-Type: application/octet-stream + +Testing 123.\n\n +-----------------------------721837373350705526688164684 +Content-Disposition: form-data; name="file3"; filename="test3.txt" +Content-Type: application/octet-stream + +Testing 123.\r\n +-----------------------------721837373350705526688164684 +Content-Disposition: form-data; name="file4"; filename="test4.txt" +Content-Type: application/octet-stream +Testing 123.\r\n\n -----------------------------721837373350705526688164684 Content-Disposition: form-data; name="submit" @@ -220,10 +234,13 @@ -----------------------------721837373350705526688164684-- """ fs = cgi.FieldStorage(fp=StringIO(postdata), environ=env) - self.assertEquals(len(fs.list), 4) + self.assertEquals(len(fs.list), 7) expect = [{'name':'id', 'filename':None, 'value':'1234'}, {'name':'title', 'filename':None, 'value':''}, - {'name':'file', 'filename':'test.txt', 'value':'Testing 123.'}, + {'name':'file', 'filename':'test.txt', 'value':'Testing 123.\n'}, + {'name':'file2', 'filename':'test2.txt', 'value':'Testing 123.\n\n'}, + {'name':'file3', 'filename':'test3.txt', 'value':'Testing 123.\r\n'}, + {'name':'file4', 'filename':'test4.txt', 'value':'Testing 123.\r\n\n'}, {'name':'submit', 'filename':None, 'value':' Add '}] for x in range(len(fs.list)): for k, exp in expect[x].items(): @@ -302,7 +319,7 @@ } result = self._qs_result.copy() result.update({ - 'upload': 'this is the content of the fake file' + 'upload': 'this is the content of the fake file\n' }) v = gen_result(data, environ) self.assertEqual(result, v)

AltStyle によって変換されたページ (->オリジナル) /