From 0917f57dbd5f6ecbb3da619227a276aa0ad66aa8 Mon Sep 17 00:00:00 2001 From: Jeena Date: Sun, 22 Mar 2026 11:09:28 +0000 Subject: [PATCH] filters: apply content filters before image-cache URL rewriting image_cache::process() percent-encodes image URLs into feedthemonkey-img:// scheme URIs (e.g. /thumbs/ becomes %2Fthumbs%2F). Filters applied after this step can no longer match the original substrings, so a rule like www.stuttmann-karikaturen.de /thumbs/ / had no effect when image caching was enabled. Fix by applying filters to the raw article content before passing it to image_cache::process(), so the corrected URLs are what get encoded into the cache scheme. The render-time filter pass in load_article_in_webview remains as a no-op for already-filtered content and still works correctly for the non-cached code path. --- src/window.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/window.rs b/src/window.rs index cd61845..8139c95 100644 --- a/src/window.rs +++ b/src/window.rs @@ -648,7 +648,11 @@ pub mod imp { let Some(api) = api else { return }; // Reload filter rules on every refresh so edits take effect immediately. - *self.filter_rules.borrow_mut() = crate::filters::load_rules(); + let filter_text = { + let settings = gio::Settings::new("net.jeena.FeedTheMonkey"); + settings.string("content-filters").to_string() + }; + *self.filter_rules.borrow_mut() = crate::filters::parse(&filter_text); self.refresh_stack.set_visible_child_name("spinner"); self.content_refresh_stack.set_visible_child_name("spinner"); @@ -675,6 +679,17 @@ pub mod imp { crate::pending_actions::flush(&api, wt).await; } let articles = api.fetch_unread().await?; + // Apply filters before image-cache processing so that rules + // such as /thumbs/ → / rewrite the original URLs before they + // are percent-encoded into feedthemonkey-img:// scheme URIs. + let rules = crate::filters::parse(&filter_text); + let articles: Vec<_> = articles + .into_iter() + .map(|mut a| { + a.content = crate::filters::apply(&rules, &a.id, &a.link, &a.content); + a + }) + .collect(); let articles = if cache_images { let processed = crate::image_cache::process(articles); crate::runtime::spawn_bg(crate::image_cache::prefetch(processed.clone()));