From 5ecd60b8a9ba3458b30a102fe74abed357ccae3d Mon Sep 17 00:00:00 2001 From: rmz-oz <262968088+rmz-oz@users.noreply.github.com> Date: Mon, 28 Sep 2026 06:41:40 +0300 Subject: [PATCH] Keep encoded # in ZIM paths when building document URIs A `%23` in the path or query of an original URL is decoded to a literal `#` in the ZIM path, as expected. But get_document_uri() then passed that ZIM path to urlsplit(), which treated the `#` as a fragment delimiter and silently dropped everything after it. The rewritten link therefore pointed to another (usually missing) ZIM entry, e.g. `a/b%23c` was rewritten to `a/b`. Tell urlsplit() not to look for a fragment: a ZIM path is never encoded, so the `#` is part of the path. It is then re-encoded to `%23` by the existing quote() call, which matches what the JS side (wombatSetup.js) already produces via encodeURIComponent(). Fix #341 --- CHANGELOG.md | 1 + src/zimscraperlib/rewriting/url_rewriting.py | 4 ++- tests/rewriting/test_url_rewriting.py | 33 ++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a29db71..d40b54f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Carry a script's top-level `const`, `let` and `class` declarations across the wombat block, so other scripts on the page can still see them (#329) - Keep a rewritten `