[3.14] gh-133889: Only show the path of the URL in the SimpleHTTPRequestHandler page (GH-134135) (GH-134190)

The query and fragment are ambiguous and not used.
(cherry picked from commit 5cbc8c632e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-05-18 21:16:37 +02:00 committed by GitHub
parent 76957eb8cc
commit 70735878ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 8 deletions

View file

@ -840,11 +840,14 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
return None
list.sort(key=lambda a: a.lower())
r = []
displaypath = self.path
displaypath = displaypath.split('#', 1)[0]
displaypath = displaypath.split('?', 1)[0]
try:
displaypath = urllib.parse.unquote(self.path,
displaypath = urllib.parse.unquote(displaypath,
errors='surrogatepass')
except UnicodeDecodeError:
displaypath = urllib.parse.unquote(self.path)
displaypath = urllib.parse.unquote(displaypath)
displaypath = html.escape(displaypath, quote=False)
enc = sys.getfilesystemencoding()
title = f'Directory listing for {displaypath}'