From 1d4f9ea898e024a4733cf9db49dd4506a9c5acb3 Mon Sep 17 00:00:00 2001 From: benoit74 Date: Sun, 8 Nov 2026 13:18:24 +0000 Subject: [PATCH] Patch vendored wombat.js so retrieveWBOSRCAsURL resolves against the frame's true URL retrieveWBOSRCAsURL (added in #386) resolved a server-recorded original attribute value against ownerDocument's replay-time baseURI. For a page whose own URL was changed by a fuzzy rule when it was stored in the ZIM (e.g. YouTube's embed page, served under youtube.fuzzy.replayweb.page/... while its real URL is www.youtube.com/embed/...), that's not the frame's true original URL, so a relative recorded value resolved to the wrong host -- the fuzzy-normalized replay path instead of the real one -- and a later fetch built from it 404'd, breaking playback. wb_info.url already holds the frame's true original URL (used the same way for Location getters, #384); resolve against that instead, via a {baseURI: wb_info.url} stand-in so resolveRelUrl's own fallback chain still applies if wb_info.url isn't set. Fixes #398 --- CHANGELOG.md | 1 + rules/patch_wombat.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce781f9..a482956 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Keep escaped Unicode characters in CSS strings instead of turning them into literal characters when rewriting (#377) - Patch vendored `wombat.js` so element properties (`img.src`, `script.src`, `link.href`, `a.href` and its derived `.pathname`/`.search`/..., `Attr.value`) return and forget a server-side-rewriter-recorded original the same way `getAttribute` already does (#386, webrecorder/wombat#240) - Detect `export const`/`let`/`var`/`function`/`async function`/`*` as module code (`EXPORT_RX` only recognized `export {...}`, `export default` and `export class`), fixing JS rewriting wrongly injecting a non-module `let arguments;` wrapper into ES modules using these common export forms, which is a syntax error in strict/module code (#387) +- Patch vendored `wombat.js` so `retrieveWBOSRCAsURL` (the helper behind the above element-property fix) resolves a recorded original against the frame's true original URL (`wb_info.url`) instead of its replay-time `ownerDocument`, fixing it returning/using a URL under the wrong host for a page whose own URL was changed by a fuzzy rule (e.g. YouTube embeds), which broke playback (#398) ## [5.5.2] - 2026-11-06 diff --git a/rules/patch_wombat.py b/rules/patch_wombat.py index 1131a36..e0d8a3a 100644 --- a/rules/patch_wombat.py +++ b/rules/patch_wombat.py @@ -216,7 +216,15 @@ # Location getters above, cannot reverse our own urlRewriteFunction's # path+query flattening. `retrieveWBOSRCAsURL` is a new helper, resolving a # recorded original the way the browser resolves these properties (as an -# absolute URL), reusing wombat's own `resolveRelUrl`. +# absolute URL). +# +# The recorded original is a literal snapshot of the attribute as it stood +# in the source HTML, so it must be resolved against that source document's +# *true* URL (`wb_info.url`) -- not `ownerDocument`'s replay-time one, which +# can diverge from it, e.g. a page served under a fuzzy-rule-normalized +# path (openzim/python-scraperlib#398). Passing a `{baseURI: wb_info.url}` +# stand-in into wombat's own `resolveRelUrl` reuses its existing fallback chain +# (current/top document baseURI) for the rare case `wb_info.url` isn't set. # # Each property's setter is also patched to forget the recorded original # (via `removeWBOSRC`) when the property is assigned, same as `setAttribute` @@ -241,7 +249,8 @@ "wb_getAttribute.call(t,i):t.getAttribute(i);return null==o?void 0:o}}," "b.prototype.retrieveWBOSRCAsURL=function(t,e){if(!t||1!==t.nodeType||" "!t.hasAttribute(e))return;var r=this.retrieveWBOSRC(t,e);if(!r)" - "return;try{return this.resolveRelUrl(r,t.ownerDocument)}catch(i){" + "return;try{return this.resolveRelUrl(r,{baseURI:this.wb_info&&" + "this.wb_info.url})}catch(i){" "return}}" )