]> granicus.if.org Git - python/commitdiff
Issue #16301: Fix the localhost verification in urllib/request.py for file://. Modify...
authorSenthil Kumaran <senthil@uthcode.com>
Mon, 22 Oct 2012 16:43:04 +0000 (09:43 -0700)
committerSenthil Kumaran <senthil@uthcode.com>
Mon, 22 Oct 2012 16:43:04 +0000 (09:43 -0700)
Lib/test/test_urllib.py
Lib/urllib/request.py
Misc/NEWS

index 85e54bff92c94aac6ebb324d5aacca7c678b34c4..e2d306fc2891cd82edc01b2aa228901af4567d6f 100644 (file)
@@ -277,7 +277,7 @@ Content-Type: text/html; charset=iso-8859-1
 
     def test_file_notexists(self):
         fd, tmp_file = tempfile.mkstemp()
-        tmp_fileurl = 'file://' + tmp_file
+        tmp_fileurl = 'file://localhost' + tmp_file
 
         self.assertTrue(os.path.exists(tmp_file))
         self.assertTrue(urlopen(tmp_fileurl))
index f2ea952639032dcbfc90bad6aca6ef615f85219b..2de3b99d9c668e7e29022d17066539308686d566 100644 (file)
@@ -1905,7 +1905,7 @@ class URLopener:
             return addinfourl(open(localname, 'rb'), headers, urlfile)
         host, port = splitport(host)
         if (not port
-           and socket.gethostbyname(host) in (localhost() + thishost())):
+           and socket.gethostbyname(host) in ((localhost(),) + thishost())):
             urlfile = file
             if file[:1] == '/':
                 urlfile = 'file://' + file
index fd82353e54f11a1a8d9a2d28a0c4dceeac80689a..47107b5ba4c5feb99c75a036ed322a8efbb7f388 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -59,6 +59,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #16301: Fix the localhost verification in urllib/request.py for file://
+  urls.
+
 - Issue #16250: Fix the invocations of URLError which had misplaced filename
   attribute for exception.