Commit 723a7a6d authored by Senthil Kumaran's avatar Senthil Kumaran

Merged revisions 86520 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r86520 | senthil.kumaran | 2010-11-18 23:36:41 +0800 (Thu, 18 Nov 2010) | 3 lines

  Fix Issue2244 - urllib unquotes user and password info multiple times - Patch by Theodore Turocy
........
parent f2849f0f
...@@ -632,22 +632,32 @@ class HandlerTests(unittest.TestCase): ...@@ -632,22 +632,32 @@ class HandlerTests(unittest.TestCase):
h = NullFTPHandler(data) h = NullFTPHandler(data)
o = h.parent = MockOpener() 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", ("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"), ["foo", "bar"], "baz.html", "text/html"),
("ftp://localhost:80/foo/bar/", ("ftp://localhost:80/foo/bar/",
"localhost", 80, "D", "localhost", 80, "", "", "D",
["foo", "bar"], "", None), ["foo", "bar"], "", None),
("ftp://localhost/baz.gif;type=a", ("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 [], "baz.gif", None), # XXX really this should guess image/gif
]: ]:
req = Request(url) req = Request(url)
req.timeout = None req.timeout = None
r = h.ftp_open(req) r = h.ftp_open(req)
# ftp authentication not yet implemented by FTPHandler # 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.host, socket.gethostbyname(host))
self.assertEqual(h.port, port) self.assertEqual(h.port, port)
self.assertEqual(h.dirs, dirs) self.assertEqual(h.dirs, dirs)
......
...@@ -700,7 +700,7 @@ def splituser(host): ...@@ -700,7 +700,7 @@ def splituser(host):
_userprog = re.compile('^(.*)@(.*)$') _userprog = re.compile('^(.*)@(.*)$')
match = _userprog.match(host) match = _userprog.match(host)
if match: return map(unquote, match.group(1, 2)) if match: return match.group(1, 2)
return None, host return None, host
_passwdprog = None _passwdprog = None
......
...@@ -1275,8 +1275,8 @@ class FTPHandler(BaseHandler): ...@@ -1275,8 +1275,8 @@ class FTPHandler(BaseHandler):
else: else:
passwd = None passwd = None
host = unquote(host) host = unquote(host)
user = unquote(user or '') user = user or ''
passwd = unquote(passwd or '') passwd = passwd or ''
try: try:
host = socket.gethostbyname(host) host = socket.gethostbyname(host)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment