cpython: 514994d7a9f2 (original) (raw)
Mercurial > cpython
changeset 74548:514994d7a9f2 3.2
Fix Issue6631 - Disallow relative file paths in urllib urlopen
Senthil Kumaran senthil@uthcode.com | |
---|---|
date | Sat, 21 Jan 2012 11:52:48 +0800 |
parents | 76077971ee1f |
children | 784f466a78e0 79e7c5841e66 |
files | Lib/test/test_urllib.py Lib/test/test_urllib2net.py Lib/urllib/request.py Misc/NEWS |
diffstat | 4 files changed, 9 insertions(+), 0 deletions(-)[+] [-] Lib/test/test_urllib.py 3 Lib/test/test_urllib2net.py 2 Lib/urllib/request.py 2 Misc/NEWS 2 |
line wrap: on
line diff
--- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -160,6 +160,9 @@ class urlopen_FileTests(unittest.TestCas for line in self.returned_obj: self.assertEqual(line, self.text)
- def test_relativelocalfile(self):
self.assertRaises(ValueError,urllib.request.urlopen,'./' + self.pathname)[](#l1.8)
+ class ProxyTests(unittest.TestCase): def setUp(self):
--- a/Lib/test/test_urllib2net.py +++ b/Lib/test/test_urllib2net.py @@ -125,6 +125,8 @@ class OtherNetworkTests(unittest.TestCas finally: os.remove(TESTFN)
self.assertRaises(ValueError, urllib.request.urlopen,'./relative_path/to/file')[](#l2.7)
+ # XXX Following test depends on machine configurations that are internal # to CNRI. Need to set up a public server with the right authentication # configuration for test purposes.
--- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1781,6 +1781,8 @@ class URLopener: urlfile = file if file[:1] == '/': urlfile = 'file://' + file
elif file[:2] == './':[](#l3.7)
raise ValueError("local file url may start with / or file:. Unknown url of type: %s" % url)[](#l3.8) return addinfourl(open(localname, 'rb'), headers, urlfile)[](#l3.9) raise URLError('local file error', 'not on local host')[](#l3.10)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -103,6 +103,8 @@ Core and Builtins Library ------- +- Issue #6631: Disallow relative file paths in urllib urlopen methods. +