kiwix-js icon indicating copy to clipboard operation
kiwix-js copied to clipboard

Work around the workaround: deal with querystrings in zimit2 ZIMs where the URL separators have been encoded

Open Jaifroid opened this issue 1 year ago • 1 comments
trafficstars

Pending the outcome of https://github.com/openzim/libzim/issues/865, we may need to introduce a workaround in Kiwix JS readers.

See original issue for full detail, but the summary is that, on HTML pages that have been encoded by warc2zim2, querystrings are incorrectly presented with encoded separators (whereas those separators are not encoded in the ZIM URL). For example, index.html?thematique=internet might be presented as index.html%3Fthematique%3Dinternet. This currently causes KJS to fail, as it (correctly) does decodeURI() when converting the HTML representation to a ZIM URL, not decodeURIComponent().

If we decode the URI separators as well, then we could be left with anomalous situations like what_is_a_cookie?.html?title=What is a cookie?&theme=dark. So we will have to take care in such situations with how we handle the querystring.

Jaifroid avatar Mar 14 '24 13:03 Jaifroid