mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
[3.14] gh-134098: Fix handling %-encoded trailing slash in SimpleHTTPRequestHandler (GH-134099) (GH-134123)
(cherry picked from commit 2f1ecb3bc4
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
5cdad8c90c
commit
d7230e1110
3 changed files with 17 additions and 4 deletions
|
@ -692,10 +692,19 @@ class SimpleHTTPServerTestCase(BaseTestCase):
|
|||
# check for trailing "/" which should return 404. See Issue17324
|
||||
response = self.request(self.base_url + '/test/')
|
||||
self.check_status_and_reason(response, HTTPStatus.NOT_FOUND)
|
||||
response = self.request(self.base_url + '/test%2f')
|
||||
self.check_status_and_reason(response, HTTPStatus.NOT_FOUND)
|
||||
response = self.request(self.base_url + '/test%2F')
|
||||
self.check_status_and_reason(response, HTTPStatus.NOT_FOUND)
|
||||
response = self.request(self.base_url + '/')
|
||||
self.check_status_and_reason(response, HTTPStatus.OK)
|
||||
response = self.request(self.base_url + '%2f')
|
||||
self.check_status_and_reason(response, HTTPStatus.OK)
|
||||
response = self.request(self.base_url + '%2F')
|
||||
self.check_status_and_reason(response, HTTPStatus.OK)
|
||||
response = self.request(self.base_url)
|
||||
self.check_status_and_reason(response, HTTPStatus.MOVED_PERMANENTLY)
|
||||
self.assertEqual(response.getheader("Location"), self.base_url + "/")
|
||||
self.assertEqual(response.getheader("Content-Length"), "0")
|
||||
response = self.request(self.base_url + '/?hi=2')
|
||||
self.check_status_and_reason(response, HTTPStatus.OK)
|
||||
|
@ -801,6 +810,8 @@ class SimpleHTTPServerTestCase(BaseTestCase):
|
|||
self.check_status_and_reason(response, HTTPStatus.OK)
|
||||
response = self.request(self.tempdir_name)
|
||||
self.check_status_and_reason(response, HTTPStatus.MOVED_PERMANENTLY)
|
||||
self.assertEqual(response.getheader("Location"),
|
||||
self.tempdir_name + "/")
|
||||
response = self.request(self.tempdir_name + '/?hi=2')
|
||||
self.check_status_and_reason(response, HTTPStatus.OK)
|
||||
response = self.request(self.tempdir_name + '?hi=1')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue