summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2011-06-09 19:05:57 (GMT)
committerR David Murray <rdmurray@bitdance.com>2011-06-09 19:05:57 (GMT)
commit0f663d07e669c39ce9a7ddfa71ed1293379a358e (patch)
tree10a53c305cd4812929a1519ae61e7aaa12798ff7
parent8168d10ea683d939ae52a1ed3d7c697c92bfae3d (diff)
downloadcpython-0f663d07e669c39ce9a7ddfa71ed1293379a358e.zip
cpython-0f663d07e669c39ce9a7ddfa71ed1293379a358e.tar.gz
cpython-0f663d07e669c39ce9a7ddfa71ed1293379a358e.tar.bz2
#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.
-rwxr-xr-xLib/smtplib.py2
-rw-r--r--Lib/test/test_smtplib.py15
-rw-r--r--Misc/NEWS2
3 files changed, 18 insertions, 1 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index dbccf48..ce71699 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -162,7 +162,7 @@ def quotedata(data):
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
index 884529f..dd92044 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -278,6 +278,21 @@ class DebuggingServerTests(unittest.TestCase):
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
index c5d2cec..dab5355 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -22,6 +22,8 @@ Core and Builtins
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.