Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b38b5c4

Browse files
committed
merge with 3.3
1 parent 6093a12 commit b38b5c4

6 files changed

Lines changed: 43 additions & 5 deletions

File tree

.hgtags

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ d047928ae3f6314a13b6137051315453d0ae89b6 v3.3.2
118118
fd53c500f8b80f54f3ecedec9da2e8c7e52a6888 v3.3.3rc1
119119
d32442c0e60dfbd71234e807d3d1dedd227495a9 v3.3.3rc2
120120
c3896275c0f61b2510a6c7e6c458a750359a91b8 v3.3.3
121+
fa92f5f940c6c0d839d7f0611e4b717606504a3c v3.3.4rc1
122+
7ff62415e4263c432c8acf6e424224209211eadb v3.3.4
121123
46535f65e7f3bcdcf176f36d34bc1fed719ffd2b v3.4.0a1
122124
9265a2168e2cb2a84785d8717792acc661e6b692 v3.4.0a2
123125
dd9cdf90a5073510877e9dd5112f8e6cf20d5e89 v3.4.0a3

Doc/tools/sphinxext/susp-ignored.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,4 @@ whatsnew/changelog,,:PythonCmd,"With Tk < 8.5 _tkinter.c:PythonCmd() raised Unic
282282
whatsnew/changelog,,::,": Fix FTP tests for IPv6, bind to ""::1"" instead of ""localhost""."
283283
whatsnew/changelog,,::,": Use ""127.0.0.1"" or ""::1"" instead of ""localhost"" as much as"
284284
whatsnew/changelog,,:password,user:password
285+
whatsnew/changelog,,:gz,w:gz

Lib/idlelib/NEWS.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,4 +875,3 @@ What's New in IDLEfork 0.9 Alpha 1?
875875
--------------------------------------------------------------------
876876
Refer to HISTORY.txt for additional information on earlier releases.
877877
--------------------------------------------------------------------
878-

Lib/smtplib.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
SMTP_SSL_PORT = 465
6363
CRLF = "\r\n"
6464
bCRLF = b"\r\n"
65+
_MAXLINE = 8192 # more than 8 times larger than RFC 821, 4.5.3
6566

6667
OLDSTYLE_AUTH = re.compile(r"auth=(.*)", re.I)
6768

@@ -365,7 +366,7 @@ def getreply(self):
365366
self.file = self.sock.makefile('rb')
366367
while 1:
367368
try:
368-
line = self.file.readline()
369+
line = self.file.readline(_MAXLINE + 1)
369370
except OSError as e:
370371
self.close()
371372
raise SMTPServerDisconnected("Connection unexpectedly closed: "
@@ -375,6 +376,8 @@ def getreply(self):
375376
raise SMTPServerDisconnected("Connection unexpectedly closed")
376377
if self.debuglevel > 0:
377378
print('reply:', repr(line), file=stderr)
379+
if len(line) > _MAXLINE:
380+
raise SMTPResponseException(500, "Line too long.")
378381
resp.append(line[4:].strip(b' \t\r\n'))
379382
code = line[:3]
380383
# Check that the error code is syntactically correct.

Lib/test/mock_socket.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ class MockFile:
2121
"""
2222
def __init__(self, lines):
2323
self.lines = lines
24-
def readline(self):
25-
return self.lines.pop(0) + b'\r\n'
24+
def readline(self, limit=-1):
25+
result = self.lines.pop(0) + b'\r\n'
26+
if limit >= 0:
27+
# Re-insert the line, removing the \r\n we added.
28+
self.lines.insert(0, result[limit:-2])
29+
result = result[:limit]
30+
return result
2631
def close(self):
2732
pass
2833

Lib/test/test_smtplib.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,33 @@ def testFailingHELO(self):
563563
HOST, self.port, 'localhost', 3)
564564

565565

566+
@unittest.skipUnless(threading, 'Threading required for this test.')
567+
class TooLongLineTests(unittest.TestCase):
568+
respdata = b'250 OK' + (b'.' * smtplib._MAXLINE * 2) + b'\n'
569+
570+
def setUp(self):
571+
self.old_stdout = sys.stdout
572+
self.output = io.StringIO()
573+
sys.stdout = self.output
574+
575+
self.evt = threading.Event()
576+
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
577+
self.sock.settimeout(15)
578+
self.port = support.bind_port(self.sock)
579+
servargs = (self.evt, self.respdata, self.sock)
580+
threading.Thread(target=server, args=servargs).start()
581+
self.evt.wait()
582+
self.evt.clear()
583+
584+
def tearDown(self):
585+
self.evt.wait()
586+
sys.stdout = self.old_stdout
587+
588+
def testLineTooLong(self):
589+
self.assertRaises(smtplib.SMTPResponseException, smtplib.SMTP,
590+
HOST, self.port, 'localhost', 3)
591+
592+
566593
sim_users = {'[email protected]':'John A',
567594
'[email protected]':'Sally B',
568595
'[email protected]':'Ruth C',
@@ -888,7 +915,8 @@ def found_terminator(self):
888915
def test_main(verbose=None):
889916
support.run_unittest(GeneralTests, DebuggingServerTests,
890917
NonConnectingTests,
891-
BadHELOServerTests, SMTPSimTests)
918+
BadHELOServerTests, SMTPSimTests,
919+
TooLongLineTests)
892920

893921
if __name__ == '__main__':
894922
test_main()

0 commit comments

Comments
 (0)