mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
url unquote the path before checking if it refers to a CGI script (closes #21766)
This commit is contained in:
parent
49991deb6e
commit
73b8b1cdb8
3 changed files with 9 additions and 1 deletions
|
|
@ -946,7 +946,7 @@ def is_cgi(self):
|
|||
(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.parse.unquote(self.path))
|
||||
dir_sep = collapsed_path.find('/', 1)
|
||||
head, tail = collapsed_path[:dir_sep], collapsed_path[dir_sep+1:]
|
||||
if head in self.cgi_directories:
|
||||
|
|
|
|||
|
|
@ -461,6 +461,11 @@ def test_os_environ_is_not_altered(self):
|
|||
(res.read(), res.getheader('Content-type'), res.status))
|
||||
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 SocketlessRequestHandler(SimpleHTTPRequestHandler):
|
||||
def __init__(self):
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ What's New in Python 3.2.6?
|
|||
Library
|
||||
-------
|
||||
|
||||
- Issue #21766: Prevent a security hole in CGIHTTPServer by URL unquoting paths
|
||||
before checking for a CGI script at that path.
|
||||
|
||||
- Fix arbitrary memory access in JSONDecoder.raw_decode with a negative second
|
||||
parameter. Bug reported by Guido Vranken.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue