Repository navigation
Fix JS URL rewriter confusing %2B with raw + in query strings - #390
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #390 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 42 42
Lines 2937 2937
Branches 450 450
=========================================
Hits 2937 2937 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
benoit74
force-pushed
the
benoit74/fix-wombat-plus-query-encoding
branch
from
November 8, 2026 20:42
e460ce3 to
c6c5a0d
Compare
wombatSetup.js decoded the query string with decodeURIComponent() before replacing '+' with ' ', so a literal '+' that had been correctly percent-encoded as '%2B' (meaning "real plus sign") got turned back into '+' by the decode, then immediately smashed into a space by the replace - indistinguishable from a raw, unencoded '+' (which means "space", by convention). Apply the substitution on the still-encoded query string instead, before decoding, matching the order already used by the Python implementation (url_rewriting.py). Found while verifying the fix for openzim/warc2zim#327: MDN's "Try it" live-sample iframes use a base64-encoded `state` query parameter, which legitimately contains '+' characters; those got corrupted into spaces, so the ZIM path built from the rewritten URL no longer matched the WARC record and the iframe 404'd. (#389)
benoit74
force-pushed
the
benoit74/fix-wombat-plus-query-encoding
branch
from
November 8, 2026 20:44
c6c5a0d to
a9c25a3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wombatSetup.js'surlRewriteFunctiondecoded the query string withdecodeURIComponent()before replacing+with' '. A literal+correctly percent-encoded as%2B(meaning "a real plus sign") got turned back into a raw+by the decode step, then immediately collapsed into a space by the replace — indistinguishable from a genuinely raw, unencoded+(which means "space", by convention, same as Python'surl_rewriting.pyalready implements).+->' 'substitution on the still-encoded query string, before decoding — matching the order the Python implementation already uses.contentWithQueryValueRawPlusSign/contentWithQueryValueEncodedPlusSign).Fixes #389, found while finishing verification of #387/#388 (openzim/warc2zim#327): MDN's "Try it" live-sample iframes build their URL with a base64-encoded
statequery parameter, which legitimately contains+characters. Those were corrupted into spaces, so the ZIM path computed from the rewritten URL no longer matched the WARC record, and the iframe 404'd instead of rendering the demo.Verified against a real test ZIM built from a crawl of MDN's
<section>reference page: with this fix (and #387/#388), the "Before"/"After" and "Using a section without a heading" live-sample demos now render their actual content instead of staying blank/404.