summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2015-10-03 06:03:25 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2015-10-03 06:03:25 (GMT)
commit56b76d25dda22ed4d0a66b50e914920a4791f664 (patch)
tree47df32d5d700fca34a54e8cc94a449236acd3881 /Lib/test
parent103d06c81e0dcf57673072cedeedcffb2f3e73cc (diff)
parentcb29e8c0e5dc67c5f73926ea0c540612ca40714a (diff)
downloadcpython-56b76d25dda22ed4d0a66b50e914920a4791f664.zip
cpython-56b76d25dda22ed4d0a66b50e914920a4791f664.tar.gz
cpython-56b76d25dda22ed4d0a66b50e914920a4791f664.tar.bz2
Issues #25232, #24657: Merge two CGI server fixes from 3.4 into 3.5
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_httpservers.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index 518e38e..50244c6 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -425,6 +425,16 @@ print("%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"),
form.getfirst("bacon")))
"""
+cgi_file4 = """\
+#!%s
+import os
+
+print("Content-type: text/html")
+print()
+
+print(os.environ["%s"])
+"""
+
@unittest.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0,
"This test can't be run reliably as root (issue #13308).")
@@ -446,6 +456,7 @@ class CGIHTTPServerTestCase(BaseTestCase):
self.file1_path = None
self.file2_path = None
self.file3_path = None
+ self.file4_path = None
# The shebang line should be pure ASCII: use symlink if possible.
# See issue #7668.
@@ -484,6 +495,11 @@ class CGIHTTPServerTestCase(BaseTestCase):
file3.write(cgi_file1 % self.pythonexe)
os.chmod(self.file3_path, 0o777)
+ self.file4_path = os.path.join(self.cgi_dir, 'file4.py')
+ with open(self.file4_path, 'w', encoding='utf-8') as file4:
+ file4.write(cgi_file4 % (self.pythonexe, 'QUERY_STRING'))
+ os.chmod(self.file4_path, 0o777)
+
os.chdir(self.parent_dir)
def tearDown(self):
@@ -499,6 +515,8 @@ class CGIHTTPServerTestCase(BaseTestCase):
os.remove(self.file2_path)
if self.file3_path:
os.remove(self.file3_path)
+ if self.file4_path:
+ os.remove(self.file4_path)
os.rmdir(self.cgi_child_dir)
os.rmdir(self.cgi_dir)
os.rmdir(self.parent_dir)
@@ -606,6 +624,19 @@ class CGIHTTPServerTestCase(BaseTestCase):
(b'Hello World' + self.linesep, 'text/html', HTTPStatus.OK),
(res.read(), res.getheader('Content-type'), res.status))
+ def test_query_with_multiple_question_mark(self):
+ res = self.request('/cgi-bin/file4.py?a=b?c=d')
+ self.assertEqual(
+ (b'a=b?c=d' + self.linesep, 'text/html', 200),
+ (res.read(), res.getheader('Content-type'), res.status))
+
+ def test_query_with_continuous_slashes(self):
+ res = self.request('/cgi-bin/file4.py?k=aa%2F%2Fbb&//q//p//=//a//b//')
+ self.assertEqual(
+ (b'k=aa%2F%2Fbb&//q//p//=//a//b//' + self.linesep,
+ 'text/html', 200),
+ (res.read(), res.getheader('Content-type'), res.status))
+
class SocketlessRequestHandler(SimpleHTTPRequestHandler):
def __init__(self):