diff -uNr Python-3.1.orig/Lib/email/feedparser.py Python-3.1/Lib/email/feedparser.py --- Python-3.1.orig/Lib/email/feedparser.py 2007-10-16 19:12:55.000000000 +0100 +++ Python-3.1/Lib/email/feedparser.py 2009-07-12 19:02:58.000000000 +0100 @@ -29,7 +29,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_crack = re.compile('(\r\n|\r|\n)') +NLCRE_crack = re.compile('(\r\n|\r(?!\Z)|\n)') # RFC 2822 $3.6.8 Optional fields. ftext is %d33-57 / %d59-126, Any character # except controls, SP, and ":". headerRE = re.compile(r'^(From |[\041-\071\073-\176]{1,}:|[\t ])') diff -uNr Python-3.1.orig/Lib/test/test_nlcre.py Python-3.1/Lib/test/test_nlcre.py --- Python-3.1.orig/Lib/test/test_nlcre.py 1970-01-01 01:00:00.000000000 +0100 +++ Python-3.1/Lib/test/test_nlcre.py 2009-07-12 19:00:51.000000000 +0100 @@ -0,0 +1,23 @@ +import unittest +from email.feedparser import FeedParser + +part1 = 'Content-Type: multipart/related; start=; boundary=----------1JBOHhxKNnWgkmE17ZJ2Cy\r\nContent-Location: http://localhost/page1.html\r\nSubject: =?utf-8?Q?test?=\r\nMIME-Version: 1.0\r\n\r\n------------1JBOHhxKNnWgkmE17ZJ2Cy\r' +part2 = '\nContent-Disposition: inline; filename=page1.html\r\nContent-Type: text/html; charset=UTF-8; name=page1.html\r\nContent-Id: \r\nContent-Location: http://localhost/page1.html\r\nContent-Transfer-Encoding: 8bit\r\n\r\n\r\nPage 1

page 1

\r\n------------1JBOHhxKNnWgkmE17ZJ2Cy--\r\n' +expected = '\r\nPage 1

page 1

' + + + + +class Test(unittest.TestCase): + def setUp(self): pass + + def test_nlcre(self): + feedparser = FeedParser() + feedparser.feed(part1) + feedparser.feed(part2) + m = feedparser.close() + mm = m.get_payload() + self.assertEqual(mm[0].get_payload(), expected) + +if __name__ == '__main__': + unittest.main()