Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a8c75fe

Browse files
committed
merge 3.3 (#21766)
2 parents 0220048 + 6cd1954 commit a8c75fe

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

Lib/http/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ def is_cgi(self):
977977
(and the next character is a '/' or the end of the string).
978978
979979
"""
980-
collapsed_path = _url_collapse_path(self.path)
980+
collapsed_path = _url_collapse_path(urllib.parse.unquote(self.path))
981981
dir_sep = collapsed_path.find('/', 1)
982982
head, tail = collapsed_path[:dir_sep], collapsed_path[dir_sep+1:]
983983
if head in self.cgi_directories:

Lib/test/test_httpservers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,11 @@ def test_os_environ_is_not_altered(self):
485485
(res.read(), res.getheader('Content-type'), res.status))
486486
self.assertEqual(os.environ['SERVER_SOFTWARE'], signature)
487487

488+
def test_urlquote_decoding_in_cgi_check(self):
489+
res = self.request('/cgi-bin%2ffile1.py')
490+
self.assertEqual((b'Hello World\n', 'text/html', 200),
491+
(res.read(), res.getheader('Content-type'), res.status))
492+
488493

489494
class SocketlessRequestHandler(SimpleHTTPRequestHandler):
490495
def __init__(self):

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ Library
2626
run_forever() and run_until_complete() methods of asyncio.BaseEventLoop now
2727
raise an exception if the event loop was closed.
2828

29+
- Issue #21766: Prevent a security hole in CGIHTTPServer by URL unquoting paths
30+
before checking for a CGI script at that path.
31+
2932
- Issue #21310: Fixed possible resource leak in failed open().
3033

3134
- Issue #21677: Fixed chaining nonnormalized exceptions in io close() methods.

0 commit comments

Comments
 (0)