Repository navigation
Milestone
Description
From https://farm.zimit.kiwix.org/pipeline/899453d8-6002-46a5-8c36-cc2f1c4783ef/debug
Traceback (most recent call last):
File "/usr/bin/zimit", line 8, in <module>
sys.exit(zimit.zimit())
^^^^^^^^^^^^^
File "/app/zimit/lib/python3.12/site-packages/zimit/zimit.py", line 695, in zimit
run(sys.argv[1:])
File "/app/zimit/lib/python3.12/site-packages/zimit/zimit.py", line 616, in run
return warc2zim(warc2zim_args)
^^^^^^^^^^^^^^^^^^^^^^^
File "/app/zimit/lib/python3.12/site-packages/warc2zim/main.py", line 168, in main
return converter.run()
^^^^^^^^^^^^^^^
File "/app/zimit/lib/python3.12/site-packages/warc2zim/converter.py", line 384, in run
self.add_items_for_warc_record(record)
File "/app/zimit/lib/python3.12/site-packages/warc2zim/converter.py", line 946, in add_items_for_warc_record
payload_item = WARCPayloadItem(
^^^^^^^^^^^^^^^^
File "/app/zimit/lib/python3.12/site-packages/warc2zim/items.py", line 56, in __init__
).rewrite(pre_head_template, post_head_template)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/zimit/lib/python3.12/site-packages/warc2zim/content_rewriting/generic.py", line 108, in rewrite
return self.rewrite_html(pre_head_template, post_head_template)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/zimit/lib/python3.12/site-packages/warc2zim/content_rewriting/generic.py", line 225, in rewrite_html
rel_static_prefix = self.url_rewriter.get_document_uri(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/zimit/lib/python3.12/site-packages/warc2zim/url_rewriting.py", line 354, in get_document_uri
PurePosixPath(item_url).relative_to(
File "/usr/lib/python3.12/pathlib.py", line 684, in relative_to
raise ValueError(f"'..' segment in {str(other)!r} cannot be walked")
ValueError: '..' segment in 'portalvwco.catalog.srv.br/common/nessComponents/xtree.html?css=../../prg' cannot be walked
Not sure if that's something we just cant support (if so, why are we crashing?) or a legitimate bug
Activity
[-]Rewriter choke on an URL inside a querystring[/-][+]Rewriter choke on an relative URL inside a querystring[/+]benoit74 commentedon Sep 2, 2024
Legitimate bug from my PoV, simply not something I imagined could happen ^^
[-]Rewriter choke on an relative URL inside a querystring[/-][+]Rewriter choke on a relative URL inside a querystring[/+]benoit74 commentedon Sep 2, 2024
(to be fixed in Python static rewriting and in JS dynamic rewriting for consistency)
benoit74 commentedon Jul 24, 2026
Problem is in fact a bit wider. See openzim/overview#90 which needs to be solved before we can make any progress on this issue.
benoit74 commentedon Aug 20, 2026
Things have settled in the parent: ZIM path with "dot segments" are forbidden.
Question is now how do we replace these ZIM path.
For now, we have following behavior:
https://example.com/abc/de?f=12/../34URL is assigned ZIM pathexample.com/abc/de?f=12/../34which is incorrectI see following alternatives:
example.com/abc/de?f=12/%2E%2E/34; I feel like this is pretty ugly especially because it means the relative URL to access this fromexample.com/abc/HTML page would becomede%3Ff=12/%252E%252E/34(we need to double encode the percent sign ... pretty ugly)example.com/abc/de?f=12/_../34(URL to accessabc/de%3Ff=12/_../34)example.com/abc/de?f=12//34(URL to accessabc/de%3Ff=12//34)It is important to note that:
Both are intrinsic limitations of current "zimit" approach and ZIM path requirements (no query-string, only a path ; no dot-segments now)
benoit74 commentedon Aug 20, 2026
Miss-click, and my comment was incomplete, it is now.
benoit74 commentedon Oct 20, 2026
I will move this forward with this solution for the time being:
Add
_character to transform the dot-segment/../in/_../: for instancehttps://example.com/abc/de?f=12/../34URL will become ZIM pathexample.com/abc/de?f=12/_../34(and URL to access it in previous example isabc/de%3Ff=12/_../34).This will be done for URLs containing
/../and/./or ending with/.and/..; for instance/.foo,/foo../baror/..foo/barare all fine.This will de done for both Python and JS URL rewriting.
Escape '.' and '..' path segments when normalizing URLs into ZIM paths