+9
-1
lines changedFilter options
+9
-1
lines changed Original file line number Diff line number Diff line change
@@ -187,6 +187,8 @@ def sanitize(self, s):
187
187
188
188
# Internal: send one line to the server, appending CRLF
189
189
def putline(self, line):
190
+
if '\r' in line or '\n' in line:
191
+
raise ValueError('an illegal newline character should not be contained')
190
192
line = line + CRLF
191
193
if self.debugging > 1:
192
194
print('*put*', self.sanitize(line))
Original file line number Diff line number Diff line change
@@ -482,6 +482,9 @@ def test_sanitize(self):
482
482
self.assertEqual(self.client.sanitize('PASS 12345'), repr('PASS *****'))
483
483
484
484
def test_exceptions(self):
485
+
self.assertRaises(ValueError, self.client.sendcmd, 'echo 40\r\n0')
486
+
self.assertRaises(ValueError, self.client.sendcmd, 'echo 40\n0')
487
+
self.assertRaises(ValueError, self.client.sendcmd, 'echo 40\r0')
485
488
self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 400')
486
489
self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 499')
487
490
self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 500')
@@ -490,7 +493,8 @@ def test_exceptions(self):
490
493
491
494
def test_all_errors(self):
492
495
exceptions = (ftplib.error_reply, ftplib.error_temp, ftplib.error_perm,
493
-
ftplib.error_proto, ftplib.Error, OSError, EOFError)
496
+
ftplib.error_proto, ftplib.Error, OSError,
497
+
EOFError)
494
498
for x in exceptions:
495
499
try:
496
500
raise x('exception not included in all_errors set')
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1
+
ftplib.FTP.putline() now throws ValueError on commands that contains CR or
2
+
LF. Patch by Dong-hee Na.
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