Skip to content

Handle fetch of text/plain as <pre>#8340

Merged
Alkarex merged 3 commits intoFreshRSS:edgefrom
Alkarex:handle-text-plain
Dec 24, 2025
Merged

Handle fetch of text/plain as <pre>#8340
Alkarex merged 3 commits intoFreshRSS:edgefrom
Alkarex:handle-text-plain

Conversation

@Alkarex
Copy link
Member

@Alkarex Alkarex commented Dec 23, 2025

fix #8328

Wrap text/plain Web scraping in a <pre>...</pre>

image

$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>' . htmlspecialchars($body, ENT_NOQUOTES, 'UTF-8') . '</pre>';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably add a class (not sure what exactly, something relating to extracted text perhaps?) so people can easily apply custom styles without affecting all PRE elements.

Copy link
Member

@Inverle Inverle Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<pre class="plaintext"> maybe

Copy link
Member

@Frenzie Frenzie Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't like that so I didn't suggest it, but it might do. I was thinking something like extracted-text but I'm not fond of that either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could <pre class="text-plain"> do?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good enough for me.

@Alkarex Alkarex modified the milestones: 1.29.0, 1.28.1 Dec 24, 2025
@Alkarex Alkarex merged commit ae2ab45 into FreshRSS:edge Dec 24, 2025
1 check passed
@Alkarex Alkarex deleted the handle-text-plain branch December 24, 2025 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature/Bug] Poor handling of pre-formatted plain text articles

3 participants