Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
58c60620
Commit
58c60620
authored
Jan 21, 2012
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Issue6631 - Disallow relative files paths in urllib*.open()
parent
631c2580
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
0 deletions
+7
-0
Lib/test/test_urllib.py
Lib/test/test_urllib.py
+3
-0
Lib/test/test_urllib2net.py
Lib/test/test_urllib2net.py
+2
-0
Lib/urllib.py
Lib/urllib.py
+2
-0
No files found.
Lib/test/test_urllib.py
View file @
58c60620
...
...
@@ -134,6 +134,9 @@ class urlopen_FileTests(unittest.TestCase):
for
line
in
self
.
returned_obj
.
__iter__
():
self
.
assertEqual
(
line
,
self
.
text
)
def
test_relativelocalfile
(
self
):
self
.
assertRaises
(
ValueError
,
urllib
.
urlopen
,
'./'
+
self
.
pathname
)
class
ProxyTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
Lib/test/test_urllib2net.py
View file @
58c60620
...
...
@@ -126,6 +126,8 @@ class OtherNetworkTests(unittest.TestCase):
finally
:
os
.
remove
(
TESTFN
)
self
.
assertRaises
(
ValueError
,
urllib2
.
urlopen
,
'./relative_path/to/file'
)
# 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.
...
...
Lib/urllib.py
View file @
58c60620
...
...
@@ -484,6 +484,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
)
host
,
port
=
splitport
(
host
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment