From 571da7264929569cf42df684f1bb0424a9cb50e6 Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Sun, 19 Jul 2026 14:50:59 +0200 Subject: [PATCH] fix(core): prevent lazy-resolver double-processing on Freedium reader images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _archivrResolveLazyImgs is called twice: before Readability (_pre) and after the post-body stamp pass (_post). The stamp pass sets data-archivr-src but previously left data-src/data-zoom-src/etc intact, so _post's 'lazySrc && _isPlaceholder' condition fired on the same images and rewrote src to the CDN URL — which SingleFile then tried and failed to fetch from the Freedium proxy context, redundantly. Fix: strip all lazy attrs (data-src, data-lazy-src, data-zoom-src, data-original, data-lazy) when stamping data-archivr-src. _post then finds no lazySrc on those images and skips them cleanly. Rust owns them via data-archivr-src. _post continues to handle any remaining placeholder images not covered by the stamp pass (non-Freedium reader captures). --- crates/archivr-core/src/downloader/singlefile.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/archivr-core/src/downloader/singlefile.rs b/crates/archivr-core/src/downloader/singlefile.rs index 9eacf83..996f906 100644 --- a/crates/archivr-core/src/downloader/singlefile.rs +++ b/crates/archivr-core/src/downloader/singlefile.rs @@ -95,6 +95,14 @@ const READER_MODE_SCRIPT: &str = concat!( try { lazySrc = new URL(lazySrc, _base).href; } catch(e) {} img.setAttribute('data-archivr-src', lazySrc); img.removeAttribute('loading'); + // Remove lazy attrs so _archivrResolveLazyImgs (called below) cannot + // rewrite src to a CDN URL that SingleFile cannot fetch from the proxy + // context — Rust owns these images via data-archivr-src instead. + img.removeAttribute('data-src'); + img.removeAttribute('data-lazy-src'); + img.removeAttribute('data-zoom-src'); + img.removeAttribute('data-original'); + img.removeAttribute('data-lazy'); }); var _post = _archivrResolveLazyImgs(_base); if (article.title) document.title = article.title;