From 3800ea9f652817e510a0db27bf124d2b80e7be10 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sat, 21 Jan 2012 11:52:48 +0800 Subject: Fix Issue6631 - Disallow relative file paths in urllib urlopen --- Lib/urllib/request.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Lib/urllib/request.py') diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index cf065715875..94b713e8855 100644 --- 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] == './': + raise ValueError("local file url may start with / or file:. Unknown url of type: %s" % url) return addinfourl(open(localname, 'rb'), headers, urlfile) raise URLError('local file error', 'not on local host') -- cgit v1.2.3