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
daa29d01
Commit
daa29d01
authored
Nov 18, 2010
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Issue2244 - urllib unquotes user and password info multiple times - Patch by Theodore Turocy
parent
d8b661dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
8 deletions
+18
-8
Lib/test/test_urllib2.py
Lib/test/test_urllib2.py
+15
-5
Lib/urllib/parse.py
Lib/urllib/parse.py
+1
-1
Lib/urllib/request.py
Lib/urllib/request.py
+2
-2
No files found.
Lib/test/test_urllib2.py
View file @
daa29d01
...
...
@@ -631,22 +631,32 @@ class HandlerTests(unittest.TestCase):
h
=
NullFTPHandler
(
data
)
o
=
h
.
parent
=
MockOpener
()
for
url
,
host
,
port
,
type_
,
dirs
,
filename
,
mimetype
in
[
for
url
,
host
,
port
,
user
,
passwd
,
type_
,
dirs
,
filename
,
mimetype
in
[
(
"ftp://localhost/foo/bar/baz.html"
,
"localhost"
,
ftplib
.
FTP_PORT
,
"I"
,
"localhost"
,
ftplib
.
FTP_PORT
,
""
,
""
,
"I"
,
[
"foo"
,
"bar"
],
"baz.html"
,
"text/html"
),
(
"ftp://parrot@localhost/foo/bar/baz.html"
,
"localhost"
,
ftplib
.
FTP_PORT
,
"parrot"
,
""
,
"I"
,
[
"foo"
,
"bar"
],
"baz.html"
,
"text/html"
),
(
"ftp://%25parrot@localhost/foo/bar/baz.html"
,
"localhost"
,
ftplib
.
FTP_PORT
,
"%parrot"
,
""
,
"I"
,
[
"foo"
,
"bar"
],
"baz.html"
,
"text/html"
),
(
"ftp://%2542parrot@localhost/foo/bar/baz.html"
,
"localhost"
,
ftplib
.
FTP_PORT
,
"%42parrot"
,
""
,
"I"
,
[
"foo"
,
"bar"
],
"baz.html"
,
"text/html"
),
(
"ftp://localhost:80/foo/bar/"
,
"localhost"
,
80
,
"D"
,
"localhost"
,
80
,
"
"
,
""
,
"
D"
,
[
"foo"
,
"bar"
],
""
,
None
),
(
"ftp://localhost/baz.gif;type=a"
,
"localhost"
,
ftplib
.
FTP_PORT
,
"A"
,
"localhost"
,
ftplib
.
FTP_PORT
,
"
"
,
""
,
"
A"
,
[],
"baz.gif"
,
None
),
# XXX really this should guess image/gif
]:
req
=
Request
(
url
)
req
.
timeout
=
None
r
=
h
.
ftp_open
(
req
)
# ftp authentication not yet implemented by FTPHandler
self
.
assertTrue
(
h
.
user
==
h
.
passwd
==
""
)
self
.
assertEqual
(
h
.
user
,
user
)
self
.
assertEqual
(
h
.
passwd
,
passwd
)
self
.
assertEqual
(
h
.
host
,
socket
.
gethostbyname
(
host
))
self
.
assertEqual
(
h
.
port
,
port
)
self
.
assertEqual
(
h
.
dirs
,
dirs
)
...
...
Lib/urllib/parse.py
View file @
daa29d01
...
...
@@ -711,7 +711,7 @@ def splituser(host):
_userprog
=
re
.
compile
(
'^(.*)@(.*)$'
)
match
=
_userprog
.
match
(
host
)
if
match
:
return
ma
p
(
unquote
,
match
.
group
(
1
,
2
)
)
if
match
:
return
ma
tch
.
group
(
1
,
2
)
return
None
,
host
_passwdprog
=
None
...
...
Lib/urllib/request.py
View file @
daa29d01
...
...
@@ -1300,8 +1300,8 @@ class FTPHandler(BaseHandler):
else
:
passwd
=
None
host
=
unquote
(
host
)
user
=
u
nquote
(
user
or
''
)
passwd
=
unquote
(
passwd
or
''
)
user
=
u
ser
or
''
passwd
=
passwd
or
''
try
:
host
=
socket
.
gethostbyname
(
host
)
...
...
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