Commit 3a3faad1 authored by Christian Schudt's avatar Christian Schudt

WebSocket plugin: Fix wrong namespace adding to empty elements

The old logic produced XML like:
<presence xmlns="jabber:client" from="..." to="..."><show xmlns="">xa</show><status xmlns=""/></presence>

This is basically the same fix as in 6965c13e.

Relates to OF-938.
parent 193091d7
...@@ -75,11 +75,17 @@ public class WebSocketConnection extends VirtualConnection ...@@ -75,11 +75,17 @@ public class WebSocketConnection extends VirtualConnection
@Override @Override
public void deliver(Packet packet) throws UnauthorizedException public void deliver(Packet packet) throws UnauthorizedException
{ {
final String xml;
if (Namespace.NO_NAMESPACE.equals(packet.getElement().getNamespace())) { if (Namespace.NO_NAMESPACE.equals(packet.getElement().getNamespace())) {
packet.getElement().add(Namespace.get(CLIENT_NAMESPACE)); // use string-based operation here to avoid cascading xmlns wonkery
StringBuilder packetXml = new StringBuilder(packet.toXML());
packetXml.insert(packetXml.indexOf(" "), " xmlns=\"jabber:client\"");
xml = packetXml.toString();
} else {
xml = packet.toXML();
} }
if (validate()) { if (validate()) {
deliverRawText(packet.toXML()); deliverRawText(xml);
} else { } else {
// use fallback delivery mechanism (offline) // use fallback delivery mechanism (offline)
getPacketDeliverer().deliver(packet); getPacketDeliverer().deliver(packet);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment