+10
-1
lines changedFilter options
+10
-1
lines changed Original file line number Diff line number Diff line change
@@ -185,6 +185,8 @@ def sanitize(self, s):
185
185
186
186
# Internal: send one line to the server, appending CRLF
187
187
def putline(self, line):
188
+
if '\r' in line or '\n' in line:
189
+
raise ValueError('an illegal newline character should not be contained')
188
190
line = line + CRLF
189
191
if self.debugging > 1: print('*put*', self.sanitize(line))
190
192
self.sock.sendall(line.encode(self.encoding))
Original file line number Diff line number Diff line change
@@ -480,6 +480,9 @@ def test_sanitize(self):
480
480
self.assertEqual(self.client.sanitize('PASS 12345'), repr('PASS *****'))
481
481
482
482
def test_exceptions(self):
483
+
self.assertRaises(ValueError, self.client.sendcmd, 'echo 40\r\n0')
484
+
self.assertRaises(ValueError, self.client.sendcmd, 'echo 40\n0')
485
+
self.assertRaises(ValueError, self.client.sendcmd, 'echo 40\r0')
483
486
self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 400')
484
487
self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 499')
485
488
self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 500')
@@ -488,7 +491,8 @@ def test_exceptions(self):
488
491
489
492
def test_all_errors(self):
490
493
exceptions = (ftplib.error_reply, ftplib.error_temp, ftplib.error_perm,
491
-
ftplib.error_proto, ftplib.Error, IOError, EOFError)
494
+
ftplib.error_proto, ftplib.Error, OSError,
495
+
EOFError)
492
496
for x in exceptions:
493
497
try:
494
498
raise x('exception not included in all_errors set')
Original file line number Diff line number Diff line change
@@ -39,6 +39,9 @@ Core and Builtins
39
39
Library
40
40
-------
41
41
42
+
- bpo-30119: ftplib.FTP.putline() now throws ValueError on commands that contains
43
+
CR or LF. Patch by Dong-hee Na
44
+
42
45
- [Security] bpo-30730: Prevent environment variables injection in subprocess on
43
46
Windows. Prevent passing other invalid environment variables and command arguments.
44
47
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4