[Python-checkins] cpython (3.2): #12283: Fixed regression in smtplib quoting of leading dots in DATA.

r.david.murray python-checkins at python.org
Thu Jun 9 21:21:49 CEST 2011


http://hg.python.org/cpython/rev/077b016e4a6d
changeset: 70744:077b016e4a6d
branch: 3.2
parent: 70739:260b84851d1f
user: R David Murray <rdmurray at bitdance.com>
date: Thu Jun 09 15:05:57 2011 -0400
summary:
 #12283: Fixed regression in smtplib quoting of leading dots in DATA.
I unfortunately introduced the regression when I refactored the code,
and there were no tests of quoting so it wasn't caught. Now there
is one.
files:
 Lib/smtplib.py | 2 +-
 Lib/test/test_smtplib.py | 15 +++++++++++++++
 Misc/NEWS | 2 ++
 3 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -162,7 +162,7 @@
 re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
 
 def _quote_periods(bindata):
- return re.sub(br'(?m)^\.', '..', bindata)
+ return re.sub(br'(?m)^\.', b'..', bindata)
 
 def _fix_eols(data):
 return re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data)
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -278,6 +278,21 @@
 mexpect = '%s%s\n%s' % (MSG_BEGIN, m.decode('ascii'), MSG_END)
 self.assertEqual(self.output.getvalue(), mexpect)
 
+ def testSendNeedingDotQuote(self):
+ # Issue 12283
+ m = '.A test\n.mes.sage.'
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+ smtp.sendmail('John', 'Sally', m)
+ # XXX (see comment in testSend)
+ time.sleep(0.01)
+ smtp.quit()
+
+ self.client_evt.set()
+ self.serv_evt.wait()
+ self.output.flush()
+ mexpect = '%s%s\n%s' % (MSG_BEGIN, m, MSG_END)
+ self.assertEqual(self.output.getvalue(), mexpect)
+
 def testSendMessage(self):
 m = email.mime.text.MIMEText('A test message')
 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -22,6 +22,8 @@
 Library
 -------
 
+- Issue #12283: Fixed regression in smtplib quoting of leading dots in DATA.
+
 - Issue #12168: SysLogHandler now allows NUL termination to be controlled using
 a new 'append_nul' attribute on the handler.
 
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

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