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.
This commit is contained in:
parent
126bd19770
commit
0917f57dbd
1 changed files with 16 additions and 1 deletions
|
|
@ -648,7 +648,11 @@ pub mod imp {
|
||||||
let Some(api) = api else { return };
|
let Some(api) = api else { return };
|
||||||
|
|
||||||
// Reload filter rules on every refresh so edits take effect immediately.
|
// 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.refresh_stack.set_visible_child_name("spinner");
|
||||||
self.content_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;
|
crate::pending_actions::flush(&api, wt).await;
|
||||||
}
|
}
|
||||||
let articles = api.fetch_unread().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 articles = if cache_images {
|
||||||
let processed = crate::image_cache::process(articles);
|
let processed = crate::image_cache::process(articles);
|
||||||
crate::runtime::spawn_bg(crate::image_cache::prefetch(processed.clone()));
|
crate::runtime::spawn_bg(crate::image_cache::prefetch(processed.clone()));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue