From 62949262a9805eda619a8591befc9097b05db651 Mon Sep 17 00:00:00 2001 From: IanTang Date: Thu, 6 Nov 2025 10:07:15 +0800 Subject: [PATCH 1/2] Comment out HtmlPostProcessor.clean calls Commented out HtmlPostProcessor.clean calls to prevent incorrect cleaning of documents with relative image paths. --- .../main/java/com/jocmp/capy/articles/ArticleRenderer.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/capy/src/main/java/com/jocmp/capy/articles/ArticleRenderer.kt b/capy/src/main/java/com/jocmp/capy/articles/ArticleRenderer.kt index 3d4a67097..14f985dcd 100644 --- a/capy/src/main/java/com/jocmp/capy/articles/ArticleRenderer.kt +++ b/capy/src/main/java/com/jocmp/capy/articles/ArticleRenderer.kt @@ -72,8 +72,8 @@ class ArticleRenderer( } else { article.siteURL?.let { document.setBaseUri(it) } } - - HtmlPostProcessor.clean(contentHTML, hideImages = hideImages) + //do not clean, when website use images of relative path, this code will clean wrongly + //HtmlPostProcessor.clean(contentHTML, hideImages = hideImages) document.content?.append( parseHtml( @@ -89,8 +89,8 @@ class ArticleRenderer( } document.content?.append(article.content) - - HtmlPostProcessor.clean(document, hideImages = hideImages) + //do not clean, when website use images of relative path, this code will clean wrongly + //HtmlPostProcessor.clean(document, hideImages = hideImages) } return document.html() From 20926837dd9fb7bd7ba81ca58a343c7a18705f6d Mon Sep 17 00:00:00 2001 From: IanTang Date: Thu, 6 Nov 2025 10:25:54 +0800 Subject: [PATCH 2/2] Add base URL for loading images in WebView Pass in the base URL to load images with relative paths. --- .../main/java/com/capyreader/app/ui/components/WebView.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/capyreader/app/ui/components/WebView.kt b/app/src/main/java/com/capyreader/app/ui/components/WebView.kt index e88dc5154..8c61ce640 100644 --- a/app/src/main/java/com/capyreader/app/ui/components/WebView.kt +++ b/app/src/main/java/com/capyreader/app/ui/components/WebView.kt @@ -107,9 +107,14 @@ class WebViewState( byline = article.byline(context = webView.context), colors = colors ) + //Pass in the base URL so that images with relative paths can be displayed properly. + val baseUrl = article.url.toString()?.let { url -> + val index = url.lastIndexOf('/') + 1 + url.substring(0, index) + } ?: article.siteURL webView.loadDataWithBaseURL( - null, + baseUrl, html, null, "UTF-8",