aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2025-12-24 21:38:38 +0100
committerGravatar GitHub <noreply@github.com> 2025-12-24 21:38:38 +0100
commitae2ab45266d7d580879755ac94fc0cbc0ffb4732 (patch)
tree53653e60ef3e426d398e1f783517779d85529b15 /app
parent7e5d2d07272d89044eb80821c5feefbd133ad7f7 (diff)
Handle fetch of text/plain as <pre> (#8340)
* Handle fetch of text/plain as <pre> fix https://github.com/FreshRSS/FreshRSS/issues/8328 * class="text-plain"
Diffstat (limited to 'app')
-rw-r--r--app/Utils/httpUtil.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/Utils/httpUtil.php b/app/Utils/httpUtil.php
index f5cd95738..ba63f0dde 100644
--- a/app/Utils/httpUtil.php
+++ b/app/Utils/httpUtil.php
@@ -407,7 +407,12 @@ final class FreshRSS_http_Util {
$body = self::enforceHttpEncoding($body, $c_content_type);
}
if (in_array($type, ['html'], true)) {
- $body = self::enforceHtmlBase($body, $c_effective_url);
+ if (stripos($c_content_type, 'text/plain') !== false) {
+ // Plain text to be displayed as preformatted text. Prefixed with UTF-8 BOM
+ $body = "\xEF\xBB\xBF" . '<pre class="text-plain">' . htmlspecialchars($body, ENT_NOQUOTES, 'UTF-8') . '</pre>';
+ } else {
+ $body = self::enforceHtmlBase($body, $c_effective_url);
+ }
}
}