]> granicus.if.org Git - python/commitdiff
Merged revisions 82782 via svnmerge from
authorSenthil Kumaran <orsenthil@gmail.com>
Sun, 11 Jul 2010 03:33:38 +0000 (03:33 +0000)
committerSenthil Kumaran <orsenthil@gmail.com>
Sun, 11 Jul 2010 03:33:38 +0000 (03:33 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/release27-maint

................
  r82782 | senthil.kumaran | 2010-07-11 08:48:51 +0530 (Sun, 11 Jul 2010) | 9 lines

  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.
  ........
................

Lib/test/test_urllib2.py
Lib/urllib2.py

index 43d7c3dd55175c61b7bb6555edd5a8238879e825..65ad8e307a2e3b1b698ee18b879412b4f414d9c9 100644 (file)
@@ -728,6 +728,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:
@@ -738,6 +740,7 @@ class HandlerTests(unittest.TestCase):
             else:
                 self.assert_(o.req is req)
                 self.assertEqual(req.type, "ftp")
+            self.assertEqual(req.type is "ftp", ftp)
 
     def test_http(self):
 
index 7cfbc1fdc9299553b36bb051eff363fb697ac5ab..ca74c9f22d386dba513ec6201035a435a1f31a9c 100644 (file)
@@ -1259,7 +1259,8 @@ class FileHandler(BaseHandler):
     # Use local file or FTP depending on form of URL
     def file_open(self, req):
         url = req.get_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: