FluuxIO / go-xmpp

Native Go XMPP library
https://www.process-one.net/
BSD 3-Clause "New" or "Revised" License
318 stars 63 forks source link

XEP-0045: Cannot distinguish between empty subject and no subject #167

Open ivucica opened 4 years ago

ivucica commented 4 years ago

Hi,

per https://xmpp.org/extensions/xep-0045.html#enter-subject an empty subject is permitted and necessary to complete the join process in case of no subject being specified.

If there is no subject set, the room MUST return an empty <subject/> element.

However, in the Message stanza, Subject field is a plain string (not a pointer), and the xml: field tag contains ,omitempty.

This makes it night impossible to spot an empty-subject message (or, for that matter, an empty-but-present body message).

(It might be doable by using a custom MsgExtension and doing a Get() over it, but this is inconvenient, and if possible at all, I cannot quickly think of a way to do it, given that a global type registry is involved.)

An improvement would be to simply replace the string with a *string, and evaluating whether to use omitempty.

ivucica commented 4 years ago

Additionally, empty vs non-present <body/> is relevant for XEP-0045:

Note: In accordance with the core definition of XML stanzas, any message can contain a <subject/> element; only a message that contains a <subject/> but no <body/> element shall be considered a subject change for MUC purposes.