Repository navigation
Send Mastodon plain text instead of HTML it shows literally - #447
Merged
Merged
Conversation
added 2 commits
October 23, 2026 12:09
Mastodon takes status as plain text and HTML-escapes all of it (TextFormatter#rewrite), so a post that still held editor markup published as <p>Hello <strong>x</strong></p>. Mastodon now goes through the same plain-text arm as the other networks, and the composer counts its text the same way.
…t case accurately
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A Mastodon post whose content still held editor markup went out with the tags showing:
ContentSanitizergave Mastodon its own arm (stripUnsafeHtml), which kept<p>,<strong>,<em>,<b>,<i>,<a>,<br>and<span>. It was added on 2026-04-01 (57ad4e2c7) on the assumption that Mastodon accepts an HTML subset. It does not:POST /api/v1/statusestakesstatusas "the text content of the status", and no parameter selects HTML. Forks such as glitch-soc acceptcontent_type, but we never send it.app/lib/text_formatter.rbruns every piece of text that is not a URL, hashtag or mention throughh()(an HTML escape), then builds its own<p>and<br>from line breaks withsimple_format.Text typed in today's composer is plain and was not affected. Only content that still holds HTML from the old rich editor was.
Fix
stripUnsafeHtml()and the now unusedTAG_PATTERNare gone, and the Mastodon arm ofdisplayText()too.resources/js/lib/characters.tsloses its Mastodon exception, so it still counts what the server sends. With no per-network rule left,displayText()anddisplayLength()no longer take a platform.simple_formatalready renders\n\n\nlike\n\n.Tests
sanitize()anddisplayText().MastodonPublisherTestcovers a post and a thread reply that still hold editor HTML, and checks the plain text sent in eachstatus.DisplayLengthParityTestkeeps the composer counter and the server in step.#testeas a hashtag, the link clickable and the link card.Not in this PR
>turned out not to be a problem. tdlib'sparse_html(td/telegram/MessageEntity.cpp) copies every byte except<and a decodable&as text.