Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kirill Smelkov
cpython
Commits
3800ea9f
Commit
3800ea9f
authored
13 years ago
by
Senthil Kumaran
Browse files
Options
Download
Email Patches
Plain Diff
Fix Issue6631 - Disallow relative file paths in urllib urlopen
parent
00289086
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
0 deletions
+9
-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/request.py
Lib/urllib/request.py
+2
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_urllib.py
View file @
3800ea9f
...
...
@@ -160,6 +160,9 @@ class urlopen_FileTests(unittest.TestCase):
for
line
in
self
.
returned_obj
:
self
.
assertEqual
(
line
,
self
.
text
)
def
test_relativelocalfile
(
self
):
self
.
assertRaises
(
ValueError
,
urllib
.
request
.
urlopen
,
'./'
+
self
.
pathname
)
class
ProxyTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_urllib2net.py
View file @
3800ea9f
...
...
@@ -125,6 +125,8 @@ class OtherNetworkTests(unittest.TestCase):
finally
:
os
.
remove
(
TESTFN
)
self
.
assertRaises
(
ValueError
,
urllib
.
request
.
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.
...
...
This diff is collapsed.
Click to expand it.
Lib/urllib/request.py
View file @
3800ea9f
...
...
@@ -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'
)
...
...
This diff is collapsed.
Click to expand it.
Misc/NEWS
View file @
3800ea9f
...
...
@@ -103,6 +103,8 @@ Core and Builtins
Library
-------
- Issue #6631: Disallow relative file paths in urllib urlopen methods.
- Issue #13722: Avoid silencing ImportErrors when initializing the codecs
registry.
...
...
This diff is collapsed.
Click to expand it.
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