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
8d24d77c
Commit
8d24d77c
authored
Jun 14, 2014
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
url unquote the path before checking if it refers to a CGI script (closes #21766)
parent
ce817cb3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
1 deletion
+9
-1
Lib/CGIHTTPServer.py
Lib/CGIHTTPServer.py
+1
-1
Lib/test/test_httpservers.py
Lib/test/test_httpservers.py
+5
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/CGIHTTPServer.py
View file @
8d24d77c
...
@@ -84,7 +84,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
...
@@ -84,7 +84,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
path begins with one of the strings in self.cgi_directories
path begins with one of the strings in self.cgi_directories
(and the next character is a '/' or the end of the string).
(and the next character is a '/' or the end of the string).
"""
"""
collapsed_path
=
_url_collapse_path
(
self
.
path
)
collapsed_path
=
_url_collapse_path
(
urllib
.
unquote
(
self
.
path
)
)
dir_sep
=
collapsed_path
.
find
(
'/'
,
1
)
dir_sep
=
collapsed_path
.
find
(
'/'
,
1
)
head
,
tail
=
collapsed_path
[:
dir_sep
],
collapsed_path
[
dir_sep
+
1
:]
head
,
tail
=
collapsed_path
[:
dir_sep
],
collapsed_path
[
dir_sep
+
1
:]
if
head
in
self
.
cgi_directories
:
if
head
in
self
.
cgi_directories
:
...
...
Lib/test/test_httpservers.py
View file @
8d24d77c
...
@@ -510,6 +510,11 @@ class CGIHTTPServerTestCase(BaseTestCase):
...
@@ -510,6 +510,11 @@ class CGIHTTPServerTestCase(BaseTestCase):
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
self
.
assertEqual
(
os
.
environ
[
'SERVER_SOFTWARE'
],
signature
)
self
.
assertEqual
(
os
.
environ
[
'SERVER_SOFTWARE'
],
signature
)
def
test_urlquote_decoding_in_cgi_check
(
self
):
res
=
self
.
request
(
'/cgi-bin%2ffile1.py'
)
self
.
assertEqual
((
b'Hello World
\
n
'
,
'text/html'
,
200
),
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
class
SimpleHTTPRequestHandlerTestCase
(
unittest
.
TestCase
):
class
SimpleHTTPRequestHandlerTestCase
(
unittest
.
TestCase
):
""" Test url parsing """
""" Test url parsing """
...
...
Misc/NEWS
View file @
8d24d77c
...
@@ -25,6 +25,9 @@ Core and Builtins
...
@@ -25,6 +25,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #21766: Prevent a security hole in CGIHTTPServer by URL unquoting paths
before checking for a CGI script at that path.
- Issue #21310: Fixed possible resource leak in failed open().
- Issue #21310: Fixed possible resource leak in failed open().
- Issue #21304: Backport the key derivation function hashlib.pbkdf2_hmac from
- Issue #21304: Backport the key derivation function hashlib.pbkdf2_hmac from
...
...
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