mod_websocket: Clone stanza before mutating (fixes #1398)

Checking for `stanza.attr.xmlns == nil` to determine if the stanza
object is an actual stanza (`<message>`, `<presence>` or `<iq>` in the
`jabber:client` or `jabbber:server` namespace) or some other stream
element.

Since this mutation is not reverted, it may leak to other places and
cause them to mistreat stanzas as stream elements. Especially in cases
like MUC where a single stanza is broadcast to many recipients.
This commit is contained in:
Kim Alvefur 2019-07-20 04:19:58 +02:00
parent 5399b9b905
commit 022198143d

View file

@ -285,6 +285,7 @@ function handle_request(event)
end);
add_filter(session, "stanzas/out", function(stanza)
stanza = st.clone(stanza);
local attr = stanza.attr;
attr.xmlns = attr.xmlns or xmlns_client;
if stanza.name:find("^stream:") then