Decode HTML entities in chat messages - #123
Closed
jolavillette wants to merge 1 commit into
Closed
Conversation
Chat messages are carried as HTML. renderChatMessage() strips the tags but never decodes the entities left behind, and the result goes into a mithril text node, so they reach the screen verbatim. The visible case is a plain space: RetroShare sends the message as HTML as soon as the composer holds any formatting, and QTextDocument::toHtml() turns leading and repeated spaces into , which the web UI then displays as that literal string. &, < and > were affected the same way. The three call sites that turned HTML into text carried the same sequence of replacements, so they now share htmlToText(). Decoding goes through a textarea rather than a div on purpose: the content model of a textarea is plain text, so no part of a message can be parsed into an element. Nothing is trusted as markup at any point. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Chat messages are carried as HTML.
renderChatMessage()strips the tags but never decodes the entities left behind, and the result goes into a mithril text node, so they are displayed verbatim.The visible case is a plain space: RetroShare sends the message as HTML as soon as the composer holds any formatting, and
QTextDocument::toHtml()turns leading and repeated spaces into , which the web UI then shows as that literal string.&,<and>were affected the same way.The three call sites that turned HTML into text carried the same replacements, so they now share
htmlToText(). Decoding goes through a textarea rather than a div on purpose: the content model of a textarea is plain text, so no part of a message can be parsed into an element. Nothing is trusted as markup.Tested on Linux against a Qt GUI peer: sending a message with spaces no longer shows
in the web UI.🤖 Generated with Claude Code