Blame SOURCES/00201-CVE-2014-4650.patch

ae2451
ae2451
# HG changeset patch
ae2451
# User Benjamin Peterson <benjamin@python.org>
ae2451
# Date 1402796189 25200
ae2451
# Node ID b4bab078876811c7d95231d08aa6fa7142fdda66
ae2451
# Parent  bb8b0c7fefd0c5ed99b3f336178a4f9554a1d0ef
ae2451
url unquote the path before checking if it refers to a CGI script (closes #21766)
ae2451
ae2451
diff --git a/Lib/CGIHTTPServer.py b/Lib/CGIHTTPServer.py
ae2451
--- a/Lib/CGIHTTPServer.py
ae2451
+++ b/Lib/CGIHTTPServer.py
ae2451
@@ -84,7 +84,7 @@ class CGIHTTPRequestHandler(SimpleHTTPSe
ae2451
         path begins with one of the strings in self.cgi_directories
ae2451
         (and the next character is a '/' or the end of the string).
ae2451
         """
ae2451
-        collapsed_path = _url_collapse_path(self.path)
ae2451
+        collapsed_path = _url_collapse_path(urllib.unquote(self.path))
ae2451
         dir_sep = collapsed_path.find('/', 1)
ae2451
         head, tail = collapsed_path[:dir_sep], collapsed_path[dir_sep+1:]
ae2451
         if head in self.cgi_directories:
ae2451
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
ae2451
--- a/Lib/test/test_httpservers.py
ae2451
+++ b/Lib/test/test_httpservers.py
ae2451
@@ -510,6 +510,11 @@ class CGIHTTPServerTestCase(BaseTestCase
ae2451
                 (res.read(), res.getheader('Content-type'), res.status))
ae2451
         self.assertEqual(os.environ['SERVER_SOFTWARE'], signature)
ae2451
 
ae2451
+    def test_urlquote_decoding_in_cgi_check(self):
ae2451
+        res = self.request('/cgi-bin%2ffile1.py')
ae2451
+        self.assertEqual((b'Hello World\n', 'text/html', 200),
ae2451
+                (res.read(), res.getheader('Content-type'), res.status))
ae2451
+
ae2451
 
ae2451
 class SimpleHTTPRequestHandlerTestCase(unittest.TestCase):
ae2451
     """ Test url parsing """