Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## Unreleased: pdoc next

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

## 2024-12-12: pdoc 15.0.1

Expand Down
2 changes: 2 additions & 0 deletions pdoc/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import http.server
import traceback
from typing import Mapping
import urllib.parse
import warnings
import webbrowser

Expand Down Expand Up @@ -60,6 +61,7 @@ def handle_request(self) -> str:
return "Not Found: Please normalize all module separators to '/'."
else:
module_name = path.lstrip("/").removesuffix(".html").replace("/", ".")
module_name = urllib.parse.unquote(module_name)
if module_name not in self.server.all_modules:
self.send_response(404)
self.send_header("content-type", "text/html")
Expand Down
6 changes: 6 additions & 0 deletions test/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ def test_get_module():
)


def test_get_module_url_escape_sequences():
assert b"make_dataclass" in handle_request(
b"GET /%64atac%6Ca%73se%73.html HTTP/1.1\r\n\r\n"
)


def test_get_dependency():
assert b"a template engine written in pure Python" in handle_request(
b"GET /jinja2.html HTTP/1.1\r\n\r\n"
Expand Down