A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/cpython/commit/8c2d4cf092c5f0335e7982392a33927579c4d512 below:

fix ftplib.FTP.putline() to throw an error for a ill… · python/cpython@8c2d4cf · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+9

-1

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+9

-1

lines changed Original file line number Diff line number Diff line change

@@ -186,6 +186,8 @@ def sanitize(self, s):

186 186 187 187

# Internal: send one line to the server, appending CRLF

188 188

def putline(self, line):

189 +

if '\r' in line or '\n' in line:

190 +

raise ValueError('an illegal newline character should not be contained')

189 191

line = line + CRLF

190 192

if self.debugging > 1:

191 193

print('*put*', self.sanitize(line))

Original file line number Diff line number Diff line change

@@ -484,6 +484,9 @@ def test_sanitize(self):

484 484

self.assertEqual(self.client.sanitize('PASS 12345'), repr('PASS *****'))

485 485 486 486

def test_exceptions(self):

487 +

self.assertRaises(ValueError, self.client.sendcmd, 'echo 40\r\n0')

488 +

self.assertRaises(ValueError, self.client.sendcmd, 'echo 40\n0')

489 +

self.assertRaises(ValueError, self.client.sendcmd, 'echo 40\r0')

487 490

self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 400')

488 491

self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 499')

489 492

self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 500')

@@ -492,7 +495,8 @@ def test_exceptions(self):

492 495 493 496

def test_all_errors(self):

494 497

exceptions = (ftplib.error_reply, ftplib.error_temp, ftplib.error_perm,

495 -

ftplib.error_proto, ftplib.Error, OSError, EOFError)

498 +

ftplib.error_proto, ftplib.Error, OSError,

499 +

EOFError)

496 500

for x in exceptions:

497 501

try:

498 502

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