summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_httpservers.py
diff options
context:
space:
mode:
authorNed Deily <nad@acm.org>2014-07-13 05:16:56 (GMT)
committerNed Deily <nad@acm.org>2014-07-13 05:16:56 (GMT)
commit5d0d2e6ed6b6ca99d7aa1f9a5ff9c4b0fa545f76 (patch)
tree4dafdea7ff6186c5aec284ac45080a68fdf09586 /Lib/test/test_httpservers.py
parentad5ffd4767802dfc34e3ae2d7960f1610d58cdcc (diff)
parent217f4cd7ee587310587f70c28cd3b25c722275ba (diff)
downloadcpython-5d0d2e6ed6b6ca99d7aa1f9a5ff9c4b0fa545f76.zip
cpython-5d0d2e6ed6b6ca99d7aa1f9a5ff9c4b0fa545f76.tar.gz
cpython-5d0d2e6ed6b6ca99d7aa1f9a5ff9c4b0fa545f76.tar.bz2
Issue #21323: Fix http.server to again handle scripts in CGI subdirectories,
broken by the fix for security issue #19435. Patch by Zach Byrne.
Diffstat (limited to 'Lib/test/test_httpservers.py')
-rw-r--r--Lib/test/test_httpservers.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index 15dec1c..0f4b9ba 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -346,10 +346,13 @@ class CGIHTTPServerTestCase(BaseTestCase):
self.cwd = os.getcwd()
self.parent_dir = tempfile.mkdtemp()
self.cgi_dir = os.path.join(self.parent_dir, 'cgi-bin')
+ self.cgi_child_dir = os.path.join(self.cgi_dir, 'child-dir')
os.mkdir(self.cgi_dir)
+ os.mkdir(self.cgi_child_dir)
self.nocgi_path = None
self.file1_path = None
self.file2_path = None
+ self.file3_path = None
# The shebang line should be pure ASCII: use symlink if possible.
# See issue #7668.
@@ -383,6 +386,11 @@ class CGIHTTPServerTestCase(BaseTestCase):
file2.write(cgi_file2 % self.pythonexe)
os.chmod(self.file2_path, 0o777)
+ self.file3_path = os.path.join(self.cgi_child_dir, 'file3.py')
+ with open(self.file3_path, 'w', encoding='utf-8') as file3:
+ file3.write(cgi_file1 % self.pythonexe)
+ os.chmod(self.file3_path, 0o777)
+
os.chdir(self.parent_dir)
def tearDown(self):
@@ -396,6 +404,9 @@ class CGIHTTPServerTestCase(BaseTestCase):
os.remove(self.file1_path)
if self.file2_path:
os.remove(self.file2_path)
+ if self.file3_path:
+ os.remove(self.file3_path)
+ os.rmdir(self.cgi_child_dir)
os.rmdir(self.cgi_dir)
os.rmdir(self.parent_dir)
finally:
@@ -491,6 +502,11 @@ class CGIHTTPServerTestCase(BaseTestCase):
self.assertEqual((b'Hello World' + self.linesep, 'text/html', 200),
(res.read(), res.getheader('Content-type'), res.status))
+ def test_nested_cgi_path_issue21323(self):
+ res = self.request('/cgi-bin/child-dir/file3.py')
+ self.assertEqual((b'Hello World' + self.linesep, 'text/html', 200),
+ (res.read(), res.getheader('Content-type'), res.status))
+
class SocketlessRequestHandler(SimpleHTTPRequestHandler):
def __init__(self):