Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2b1e6e96
Commit
2b1e6e96
authored
Jul 23, 2017
by
Dong-hee Na
Committed by
Giampaolo Rodola
Jul 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-30119: fix ftplib.FTP.putline() to throw an error for a illegal command (#1214)
parent
896145d9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
1 deletion
+10
-1
Lib/ftplib.py
Lib/ftplib.py
+2
-0
Lib/test/test_ftplib.py
Lib/test/test_ftplib.py
+5
-1
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/ftplib.py
View file @
2b1e6e96
...
...
@@ -186,6 +186,8 @@ class FTP:
# Internal: send one line to the server, appending CRLF
def
putline
(
self
,
line
):
if
'
\
r
'
in
line
or
'
\
n
'
in
line
:
raise
ValueError
(
'an illegal newline character should not be contained'
)
line
=
line
+
CRLF
if
self
.
debugging
>
1
:
print
(
'*put*'
,
self
.
sanitize
(
line
))
...
...
Lib/test/test_ftplib.py
View file @
2b1e6e96
...
...
@@ -485,6 +485,9 @@ class TestFTPClass(TestCase):
self
.
assertEqual
(
self
.
client
.
sanitize
(
'PASS 12345'
),
repr
(
'PASS *****'
))
def
test_exceptions
(
self
):
self
.
assertRaises
(
ValueError
,
self
.
client
.
sendcmd
,
'echo 40
\
r
\
n
0'
)
self
.
assertRaises
(
ValueError
,
self
.
client
.
sendcmd
,
'echo 40
\
n
0'
)
self
.
assertRaises
(
ValueError
,
self
.
client
.
sendcmd
,
'echo 40
\
r
0'
)
self
.
assertRaises
(
ftplib
.
error_temp
,
self
.
client
.
sendcmd
,
'echo 400'
)
self
.
assertRaises
(
ftplib
.
error_temp
,
self
.
client
.
sendcmd
,
'echo 499'
)
self
.
assertRaises
(
ftplib
.
error_perm
,
self
.
client
.
sendcmd
,
'echo 500'
)
...
...
@@ -493,7 +496,8 @@ class TestFTPClass(TestCase):
def
test_all_errors
(
self
):
exceptions
=
(
ftplib
.
error_reply
,
ftplib
.
error_temp
,
ftplib
.
error_perm
,
ftplib
.
error_proto
,
ftplib
.
Error
,
OSError
,
EOFError
)
ftplib
.
error_proto
,
ftplib
.
Error
,
OSError
,
EOFError
)
for
x
in
exceptions
:
try
:
raise
x
(
'exception not included in all_errors set'
)
...
...
Misc/NEWS
View file @
2b1e6e96
...
...
@@ -376,6 +376,9 @@ Extension Modules
Library
-------
- bpo-30119: ftplib.FTP.putline() now throws ValueError on commands that contains
CR or LF. Patch by Dong-hee Na.
- bpo-30879: os.listdir() and os.scandir() now emit bytes names when called
with bytes-like argument.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment