openzim / openzim/python-scraperlib
Rewriter choke on a relative URL inside a querystring
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 31
- Forks
- 27
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 2
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with warc2zim/url_rewriting.py at get_document_uri, then trace the call from warc2zim/content_rewriting/generic.py:225. Reproduce the failure using the relative URL and query string shown in the traceback. Done means the rewriter has defined behavior for this input and the conversion no longer crashes unexpectedly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 56/100