Commit 5b11857d authored by Dave Cridland's avatar Dave Cridland

Merge pull request #490 from sco0ter/websocket

WebSocket plugin: Fix wrong namespace adding to empty elements
parents 632eec6f 3a3faad1
...@@ -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
{ {
if (Namespace.NO_NAMESPACE.equals(packet.getElement().getNamespace())) { final String xml;
packet.getElement().add(Namespace.get(CLIENT_NAMESPACE)); if (Namespace.NO_NAMESPACE.equals(packet.getElement().getNamespace())) {
} // 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