mirror of
https://github.com/python/cpython.git
synced 2025-08-29 05:05:03 +00:00
#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.
This commit is contained in:
parent
8168d10ea6
commit
0f663d07e6
3 changed files with 18 additions and 1 deletions
|
@ -162,7 +162,7 @@ def quotedata(data):
|
||||||
re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
|
re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
|
||||||
|
|
||||||
def _quote_periods(bindata):
|
def _quote_periods(bindata):
|
||||||
return re.sub(br'(?m)^\.', '..', bindata)
|
return re.sub(br'(?m)^\.', b'..', bindata)
|
||||||
|
|
||||||
def _fix_eols(data):
|
def _fix_eols(data):
|
||||||
return re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data)
|
return re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data)
|
||||||
|
|
|
@ -278,6 +278,21 @@ class DebuggingServerTests(unittest.TestCase):
|
||||||
mexpect = '%s%s\n%s' % (MSG_BEGIN, m.decode('ascii'), MSG_END)
|
mexpect = '%s%s\n%s' % (MSG_BEGIN, m.decode('ascii'), MSG_END)
|
||||||
self.assertEqual(self.output.getvalue(), mexpect)
|
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):
|
def testSendMessage(self):
|
||||||
m = email.mime.text.MIMEText('A test message')
|
m = email.mime.text.MIMEText('A test message')
|
||||||
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
|
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
|
||||||
|
|
|
@ -22,6 +22,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #12283: Fixed regression in smtplib quoting of leading dots in DATA.
|
||||||
|
|
||||||
- Issue #12168: SysLogHandler now allows NUL termination to be controlled using
|
- Issue #12168: SysLogHandler now allows NUL termination to be controlled using
|
||||||
a new 'append_nul' attribute on the handler.
|
a new 'append_nul' attribute on the handler.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue