Commit f337ffc5 authored by Christian Schudt's avatar Christian Schudt Committed by Dave Cridland

WebSocket plugin: "lang" attribute should be "xml:lang"

Also be more correct when reading the "xml:lang" attribute and remove superfluous whitespaces.

Fixes OF-977
parent 632189b3
...@@ -50,6 +50,12 @@ Openfire WebSocket Plugin Changelog ...@@ -50,6 +50,12 @@ Openfire WebSocket Plugin Changelog
<li>Pass 'xml:lang' attribute to the session.</li> <li>Pass 'xml:lang' attribute to the session.</li>
</ul> </ul>
<p><b>1.0.1</b> -- November 21, 2015</p>
<ul>
<li>"lang" attribute should be "xml:lang" in session creation response.</li>
</ul>
<p><b>1.0</b> -- July 28, 2015</p> <p><b>1.0</b> -- July 28, 2015</p>
<ul> <ul>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<name>Openfire WebSocket</name> <name>Openfire WebSocket</name>
<description>Provides WebSocket support for Openfire.</description> <description>Provides WebSocket support for Openfire.</description>
<author>Tom Evans</author> <author>Tom Evans</author>
<version>1.0.0</version> <version>1.1.0</version>
<date>11/24/2015</date> <date>11/24/2015</date>
<url>https://tools.ietf.org/html/rfc7395</url> <url>https://tools.ietf.org/html/rfc7395</url>
<minServerVersion>3.11.0</minServerVersion> <minServerVersion>3.11.0</minServerVersion>
......
...@@ -23,6 +23,7 @@ import java.util.TimerTask; ...@@ -23,6 +23,7 @@ import java.util.TimerTask;
import org.apache.commons.pool2.impl.GenericObjectPool; import org.apache.commons.pool2.impl.GenericObjectPool;
import org.dom4j.Document; import org.dom4j.Document;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.QName;
import org.dom4j.io.XMPPPacketReader; import org.dom4j.io.XMPPPacketReader;
import org.eclipse.jetty.websocket.api.RemoteEndpoint; import org.eclipse.jetty.websocket.api.RemoteEndpoint;
import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.Session;
...@@ -48,6 +49,8 @@ import org.slf4j.LoggerFactory; ...@@ -48,6 +49,8 @@ import org.slf4j.LoggerFactory;
import org.xmpp.packet.PacketError; import org.xmpp.packet.PacketError;
import org.xmpp.packet.StreamError; import org.xmpp.packet.StreamError;
import javax.xml.XMLConstants;
/** /**
* This class handles all WebSocket events for the corresponding connection with a remote peer. * This class handles all WebSocket events for the corresponding connection with a remote peer.
* Specifically the XMPP session is managed concurrently with the WebSocket session, including all * Specifically the XMPP session is managed concurrently with the WebSocket session, including all
...@@ -212,7 +215,7 @@ public class XmppWebSocket { ...@@ -212,7 +215,7 @@ public class XmppWebSocket {
saslStatus = SASLAuthentication.handle(xmppSession, stanza); saslStatus = SASLAuthentication.handle(xmppSession, stanza);
} else if (STREAM_HEADER.equals(tag)) { } else if (STREAM_HEADER.equals(tag)) {
// restart the stream // restart the stream
openStream(stanza.attributeValue("lang", "en"), stanza.attributeValue("from")); openStream(stanza.attributeValue(QName.get("lang", XMLConstants.XML_NS_URI), "en"), stanza.attributeValue("from"));
configureStream(); configureStream();
} else if (Status.authenticated.equals(saslStatus)) { } else if (Status.authenticated.equals(saslStatus)) {
if (router == null) { if (router == null) {
...@@ -245,7 +248,7 @@ public class XmppWebSocket { ...@@ -245,7 +248,7 @@ public class XmppWebSocket {
String host = stanza.attributeValue("to"); String host = stanza.attributeValue("to");
StreamError streamError = null; StreamError streamError = null;
Locale language = Locale.forLanguageTag(stanza.attributeValue("lang", "en")); Locale language = Locale.forLanguageTag(stanza.attributeValue(QName.get("lang", XMLConstants.XML_NS_URI), "en"));
if (STREAM_FOOTER.equals(stanza.getName())) { if (STREAM_FOOTER.equals(stanza.getName())) {
// an error occurred while setting up the session // an error occurred while setting up the session
closeStream(null); closeStream(null);
...@@ -318,8 +321,8 @@ public class XmppWebSocket { ...@@ -318,8 +321,8 @@ public class XmppWebSocket {
sb.append("from='").append(XMPPServer.getInstance().getServerInfo().getXMPPDomain()).append("' "); sb.append("from='").append(XMPPServer.getInstance().getServerInfo().getXMPPDomain()).append("' ");
sb.append("id='").append(xmppSession.getStreamID().toString()).append("' "); sb.append("id='").append(xmppSession.getStreamID().toString()).append("' ");
sb.append("xmlns='").append(FRAMING_NAMESPACE).append("' "); sb.append("xmlns='").append(FRAMING_NAMESPACE).append("' ");
sb.append("lang='").append(lang).append("' "); sb.append("xml:lang='").append(lang).append("' ");
sb.append("version='1.0' />"); sb.append("version='1.0'/>");
deliver(sb.toString()); deliver(sb.toString());
} }
...@@ -333,8 +336,8 @@ public class XmppWebSocket { ...@@ -333,8 +336,8 @@ public class XmppWebSocket {
StringBuilder sb = new StringBuilder(250); StringBuilder sb = new StringBuilder(250);
sb.append("<close "); sb.append("<close ");
sb.append("xmlns='").append(FRAMING_NAMESPACE).append("' "); sb.append("xmlns='").append(FRAMING_NAMESPACE).append("'");
sb.append(" />"); sb.append("/>");
deliver(sb.toString()); deliver(sb.toString());
closeWebSocket(); closeWebSocket();
} }
......
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