Skip to content

Commit 5dc0f3b

Browse files
Fix improper handling of URL-escaped module names (#787)
* Fix improper handling of URL-escaped module names Closes #786 * [autofix.ci] apply automated fixes * Update Changelog --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 85503a1 commit 5dc0f3b

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
## Unreleased: pdoc next
66

7+
- Fix handling of URL-escaped module names ([#787](https://github.com/mitmproxy/pdoc/pull/787), @iFreilicht)
78

89
## 2024-12-12: pdoc 15.0.1
910

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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ 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+
77+
7278
def test_get_dependency():
7379
assert b"a template engine written in pure Python" in handle_request(
7480
b"GET /jinja2.html HTTP/1.1\r\n\r\n"

0 commit comments

Comments
 (0)