matrix-org/matrix-bifrost

XHTML-IM content missing required <body> tag

sporkbomb opened this issue · 1 comments

According to https://xmpp.org/extensions/xep-0071.html#concepts (and the chapters following it), XHTML-IM content is supposed to be wrapped in a <html/> tag, which must contain one or more <body/> tags.

The root element for including XHTML content within XMPP stanzas is <html/>. This element is qualified by the 'http://jabber.org/protocol/xhtml-im' namespace. From the perspective of XMPP, the wrapper element functions as an XMPP extension element; from the perspective of XHTML, it functions as a wrapper for XHTML 1.0 content qualified by the 'http://www.w3.org/1999/xhtml' namespace. Such XHTML content MUST be contained in one or more <body/> elements qualified by the 'http://www.w3.org/1999/xhtml' namespace and MUST conform to the XHTML-IM Integration Set defined in the following section.

Bifrost (or rather, the xmppjs part of it) wraps XHTML-IM content in the correct <html/> tag, but does not add the required <body/> tag.
As an example, suppose you want to embed <a href="https://foo.bar">Click me</a>. This is currently emitted as

<html xmlns='http://jabber.org/protocol/xhtml-im'>
    <a href="https://foo.bar">Click me</a>
</html>

but should instead be emitted as

<html xmlns='http://jabber.org/protocol/xhtml-im'>
    <body xmlns='http://www.w3.org/1999/xhtml'>
        <a href="https://foo.bar">Click me</a>
    </body>
</html>

Please note that this incorrect behavior is also reflected in the test cases in test/xmppjs/test_XHTMLIM.ts.

The current behavior causes clients receiving these XHTML-IM messages to fail to parse them; this includes all clients based on nbxmpp, such as Gajim.

@sporkbomb: @maranda has solved it in this PR.
Have you seen?