Matrix: formatted message bodies are ignored in both directions #50

Closed
opened 2026-08-29 09:59:48 -04:00 by Salastil · 1 comment
Owner

formatted_body appears nowhere in the Matrix backend. Only content.body is read (protocol.rs:53-57), and everything sent is msgtype: m.text with no format/formatted_body.

So inbound HTML is dropped for the plaintext fallback — code blocks, links with text, quotes and emphasis all arrive flattened — and nothing sent from moho carries formatting even though the composer can express it and every other Matrix client renders it.

There is already a sanitisation boundary to render into: lib/richtext.tsx parses restricted HTML through a tag/attribute whitelist into React nodes and never touches innerHTML, which is exactly what org.matrix.custom.html needs.

Done looks like: inbound formatted_body routed through richtext.tsx's whitelist, and outbound sending format: org.matrix.custom.html alongside a plaintext body fallback. Outgoing m.emote (/me) is missing too and belongs in the same change.


Filed from a protocol coverage survey of the four deployed protocols, 2026-08-29 (moho 1a11250, nobilis 030707f).

`formatted_body` appears nowhere in the Matrix backend. Only `content.body` is read (`protocol.rs:53-57`), and everything sent is `msgtype: m.text` with no `format`/`formatted_body`. So inbound HTML is dropped for the plaintext fallback — code blocks, links with text, quotes and emphasis all arrive flattened — and nothing sent from moho carries formatting even though the composer can express it and every other Matrix client renders it. There is already a sanitisation boundary to render into: `lib/richtext.tsx` parses restricted HTML through a tag/attribute whitelist into React nodes and never touches `innerHTML`, which is exactly what `org.matrix.custom.html` needs. **Done looks like:** inbound `formatted_body` routed through `richtext.tsx`'s whitelist, and outbound sending `format: org.matrix.custom.html` alongside a plaintext `body` fallback. Outgoing `m.emote` (`/me`) is missing too and belongs in the same change. --- _Filed from a protocol coverage survey of the four deployed protocols, 2026-08-29 (moho `1a11250`, nobilis `030707f`)._
Salastil added the feature label 2026-08-29 09:59:48 -04:00
Author
Owner

Finished for inbound — nobilis 1e11ce2, moho f98fb5e

A Matrix message carrying formatted_body is now shown with its own formatting, through the same sanitiser everything else goes through.

Outgoing is still plain text, and is split out as #54 rather than left implied here: saying it in HTML means turning what somebody typed into HTML, and there is no markdown parser in the daemon to do that honestly. Plain m.text is valid Matrix and renders correctly everywhere, so this is a missing feature rather than a broken one.

Finished for inbound — nobilis [`1e11ce2`](https://git.salastil.com/Salastil/nobilis/commit/1e11ce2), moho [`f98fb5e`](https://git.salastil.com/Salastil/moho/commit/f98fb5e) A Matrix message carrying `formatted_body` is now shown with its own formatting, through the same sanitiser everything else goes through. **Outgoing is still plain text**, and is split out as #54 rather than left implied here: saying it in HTML means turning what somebody typed into HTML, and there is no markdown parser in the daemon to do that honestly. Plain `m.text` is valid Matrix and renders correctly everywhere, so this is a missing feature rather than a broken one.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Salastil/moho#50