Commit f08bb5a
Fix crash rewriting relative document URI on
`ArticleUrlRewriter.get_document_uri` computed the relative path between two
ZIM entries by feeding `path + "?" + querystring` to `PurePosixPath`, which
splits on `/` and interprets `..` segments as directory navigation. When the
document being rewritten (or a linked item) had a querystring containing `..`
(e.g. `xtree.html?css=../../prg`), `PurePosixPath.relative_to(..., walk_up=True)`
raised `ValueError: '..' segment ... cannot be walked`, aborting the scrape.
A querystring is part of the ZIM entry name (a leaf), not a navigable
directory, so its content must not take part in the relative-path walk. Compute
the relative path from the path components only, then re-append the querystring
(url-encoded together with the path) once the relative path is known. Existing
outputs are unchanged for querystrings without `/` or `..` segments.
Fixes openzim/warc2zim#380
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>..// in querystring1 parent 295fefc commit f08bb5a
3 files changed
Lines changed: 64 additions & 12 deletions
File tree
- src/zimscraperlib/rewriting
- tests/rewriting
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
320 | 323 | | |
321 | | - | |
| 324 | + | |
322 | 325 | | |
323 | | - | |
324 | | - | |
325 | | - | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
326 | 329 | | |
327 | 330 | | |
328 | 331 | | |
329 | 332 | | |
330 | | - | |
331 | | - | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
332 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
333 | 341 | | |
334 | 342 | | |
335 | 343 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
535 | 575 | | |
536 | 576 | | |
537 | 577 | | |
| |||
0 commit comments