aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_httpservers.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2025-05-18 21:09:51 +0300
committerGitHub <noreply@github.com>2025-05-18 18:09:51 +0000
commit5cbc8c632e860941602e8f7da9aab52fae40aca6 (patch)
tree5fb7edb48e35b68f821969ff7b4e1592fa8e01c7 /Lib/test/test_httpservers.py
parentbb32f3c698f5192dddd2d2f33c7c0a3d05afc223 (diff)
downloadcpython-5cbc8c632e860941602e8f7da9aab52fae40aca6.tar.gz
cpython-5cbc8c632e860941602e8f7da9aab52fae40aca6.zip
gh-133889: Only show the path of the URL in the SimpleHTTPRequestHandler page (GH-134135)
The query and fragment are ambiguous and not used.
Diffstat (limited to 'Lib/test/test_httpservers.py')
-rw-r--r--Lib/test/test_httpservers.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index 11c74a02bf2..df5d2a7bedc 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -627,13 +627,14 @@ class SimpleHTTPServerTestCase(BaseTestCase):
self.check_list_dir_filename(filename)
os_helper.unlink(os.path.join(self.tempdir, filename))
- def test_undecodable_parameter(self):
- # sanity check using a valid parameter
+ def test_list_dir_with_query_and_fragment(self):
+ prefix = f'listing for {self.base_url}/</'.encode('latin1')
+ response = self.request(self.base_url + '/#123').read()
+ self.assertIn(prefix + b'title>', response)
+ self.assertIn(prefix + b'h1>', response)
response = self.request(self.base_url + '/?x=123').read()
- self.assertRegex(response, rf'listing for {self.base_url}/\?x=123'.encode('latin1'))
- # now the bogus encoding
- response = self.request(self.base_url + '/?x=%bb').read()
- self.assertRegex(response, rf'listing for {self.base_url}/\?x=\xef\xbf\xbd'.encode('latin1'))
+ self.assertIn(prefix + b'title>', response)
+ self.assertIn(prefix + b'h1>', response)
def test_get_dir_redirect_location_domain_injection_bug(self):
"""Ensure //evil.co/..%2f../../X does not put //evil.co/ in Location.