]> granicus.if.org Git - python/commitdiff
Merged revisions 82780 via svnmerge from
authorSenthil Kumaran <orsenthil@gmail.com>
Sun, 11 Jul 2010 03:15:25 +0000 (03:15 +0000)
committerSenthil Kumaran <orsenthil@gmail.com>
Sun, 11 Jul 2010 03:15:25 +0000 (03:15 +0000)
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.
........

Lib/test/test_urllib2.py
Lib/urllib/request.py

index 9071f4989e0faa3d8f44679bc99d756cc253b931..9d1ed9b616ab1974598e819704a2a936d634439c 100644 (file)
@@ -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):
 
index e59208ff85fe380756dde3ab4ecda5e411d10ad5..cb80a36f8ba0ab3270e5fedcb21771675f547195 100644 (file)
@@ -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: