Skip to content

Commit a6945de

Browse files
committed
Fix improper handling of URL-escaped module names
Closes #786
1 parent 85503a1 commit a6945de

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

pdoc/web.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import http.server
1515
import traceback
1616
from typing import Mapping
17+
import urllib.parse
1718
import warnings
1819
import webbrowser
1920

@@ -60,6 +61,7 @@ def handle_request(self) -> str:
6061
return "Not Found: Please normalize all module separators to '/'."
6162
else:
6263
module_name = path.lstrip("/").removesuffix(".html").replace("/", ".")
64+
module_name = urllib.parse.unquote(module_name)
6365
if module_name not in self.server.all_modules:
6466
self.send_response(404)
6567
self.send_header("content-type", "text/html")

test/test_web.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ def test_get_module():
6969
)
7070

7171

72+
def test_get_module_url_escape_sequences():
73+
assert b"make_dataclass" in handle_request(
74+
b"GET /%64atac%6Ca%73se%73.html HTTP/1.1\r\n\r\n"
75+
)
76+
7277
def test_get_dependency():
7378
assert b"a template engine written in pure Python" in handle_request(
7479
b"GET /jinja2.html HTTP/1.1\r\n\r\n"

0 commit comments

Comments
 (0)