summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2010-11-18 16:44:38 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2010-11-18 16:44:38 (GMT)
commit723a7a6d93306b3b49be3b2ebe06accb8e3fd1bc (patch)
tree4953ea259d3acae66659ba98afb02d50c05eeb0b
parentf2849f0fb445769a50b5331356f143864c5ce770 (diff)
downloadcpython-723a7a6d93306b3b49be3b2ebe06accb8e3fd1bc.zip
cpython-723a7a6d93306b3b49be3b2ebe06accb8e3fd1bc.tar.gz
cpython-723a7a6d93306b3b49be3b2ebe06accb8e3fd1bc.tar.bz2
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 ........
-rw-r--r--Lib/test/test_urllib2.py20
-rw-r--r--Lib/urllib/parse.py2
-rw-r--r--Lib/urllib/request.py4
3 files changed, 18 insertions, 8 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index 0f8395e..38cf607 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -632,22 +632,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)
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index 765f1c8..b437d6f 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -700,7 +700,7 @@ def splituser(host):
_userprog = re.compile('^(.*)@(.*)$')
match = _userprog.match(host)
- if match: return map(unquote, match.group(1, 2))
+ if match: return match.group(1, 2)
return None, host
_passwdprog = None
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index 464f847..5a67c0b 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -1275,8 +1275,8 @@ class FTPHandler(BaseHandler):
else:
passwd = None
host = unquote(host)
- user = unquote(user or '')
- passwd = unquote(passwd or '')
+ user = user or ''
+ passwd = passwd or ''
try:
host = socket.gethostbyname(host)
d> * Merged revisions 62332 via svnmerge fromBenjamin Peterson2008-04-132-0/+7 * A few io doc fixesBenjamin Peterson2008-04-131-22/+27 * Merged revisions 62260-62261,62266,62271,62277-62279,62289-62290,62293-62298,...Christian Heimes2008-04-1334-570/+1701 * Blocked revisions 62309-62310 via svnmergeBenjamin Peterson2008-04-130-0/+0 * Fleshed out docstrings in the io module, improving the reST one as I went.Benjamin Peterson2008-04-132-216/+367 * Removed unused variable.Alexandre Vassalotti2008-04-121-2/+0 * Issue 2440: revert r62269 and r62279. These changes were made in an effort t...Trent Nelson2008-04-113-21/+6 * Synced builtin open and io.open documentation, taking the best of eachBenjamin Peterson2008-04-112-102/+121 * Fix change to PyNumber_Index() made in r62269, which incorrectly allowed floa...Trent Nelson2008-04-101-1/+1 * Add a NEWS entry for issue2221.Amaury Forgeot d'Arc2008-04-102-2/+7 * Update test_ssl.py to reflect the new approach for writing network-oriented t...Trent Nelson2008-04-101-55/+26 * Revert r62242: trunk's test_ssl.py isn't as up-to-date as py3k's, and should'...Trent Nelson2008-04-101-61/+133 * Bug #2606: Avoid calling .sort() on a dict_keys object.Martin v. Löwis2008-04-102-9/+5 * Issue 2440: fix the handling of %n in Python/getargs.c's convertsimple(), ext...Trent Nelson2008-04-103-6/+21 * Merged revisions 62246-62259 via svnmerge fromMartin v. Löwis2008-04-10