Skip to content

Decode HTML entities in chat messages - #123

Closed
jolavillette wants to merge 1 commit into
RetroShare:masterfrom
jolavillette:fix/webui-chat-html-entities
Closed

Decode HTML entities in chat messages#123
jolavillette wants to merge 1 commit into
RetroShare:masterfrom
jolavillette:fix/webui-chat-html-entities

Conversation

@jolavillette

Copy link
Copy Markdown
Contributor

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

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>
@jolavillette
jolavillette deleted the fix/webui-chat-html-entities branch August 13, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant