diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2010-07-11 03:15:25 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2010-07-11 03:15:25 (GMT) |
commit | 3402414b850938a55af78fd79d7890c935dca630 (patch) | |
tree | ca85cf327f1399ae9aa09d1c4a1e3f81b17377b0 | |
parent | a755e14d14c206ada152be44cfd6fce45c3fe123 (diff) | |
download | cpython-3402414b850938a55af78fd79d7890c935dca630.zip cpython-3402414b850938a55af78fd79d7890c935dca630.tar.gz cpython-3402414b850938a55af78fd79d7890c935dca630.tar.bz2 |
Merged revisions 82780 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r82780 | senthil.kumaran | 2010-07-11 08:42:43 +0530 (Sun, 11 Jul 2010) | 3 lines
Stricter verification for file based url scheme and reliance on ftp protocol.
........
-rw-r--r-- | Lib/test/test_urllib2.py | 3 | ||||
-rw-r--r-- | Lib/urllib/request.py | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index 9071f49..9d1ed9b 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -736,6 +736,8 @@ class HandlerTests(unittest.TestCase): ("file://ftp.example.com///foo.txt", False), # XXXX bug: fails with OSError, should be URLError ("file://ftp.example.com/foo.txt", False), + ("file://somehost//foo/something.txt", True), + ("file://localhost//foo/something.txt", False), ]: req = Request(url) try: @@ -746,6 +748,7 @@ class HandlerTests(unittest.TestCase): else: self.assertTrue(o.req is req) self.assertEqual(req.type, "ftp") + self.assertEqual(req.type is "ftp", ftp) def test_http(self): diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index e59208f..cb80a36 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1188,7 +1188,8 @@ class FileHandler(BaseHandler): # Use local file or FTP depending on form of URL def file_open(self, req): url = req.selector - if url[:2] == '//' and url[2:3] != '/': + if url[:2] == '//' and url[2:3] != '/' and (req.host and + req.host != 'localhost'): req.type = 'ftp' return self.parent.open(req) else: |