Special characters in groups causes client disconnect

I’‘m not sure if this is a bug with Spark or Messenger, but here’'s what I see:

  1. Create a group with “&” in it, like “research & development”

  2. Drag a user to the new group

Spark will error out with “Your connection was closed due to server error. Would you like to log back in?” Upon logging back in, the group is gone. This appears to happen with “<” as well.

The following is in C:\Program Files\Spark\logs:

:1:175: The entity name must immediately follow the ‘’&’’ in the entity reference.

ERROR: ‘‘The entity name must immediately follow the ‘’&’’ in the entity reference.’’

org.xml.sax.SAXParseException: The entity name must immediately follow the ‘’&’’ in the entity reference.

at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity( Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)

at org.jivesoftware.smackx.debugger.EnhancedDebugger.formatXML(EnhancedDebugger.ja va:831)

at org.jivesoftware.smackx.debugger.EnhancedDebugger.access$2100(EnhancedDebugger. java:64)

at org.jivesoftware.smackx.debugger.EnhancedDebugger$21.run(EnhancedDebugger.java: 793)

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Dec 7, 2005 10:00:37 AM com.jivesoftware.Log logError

SEVERE: Connection closed on error.

No response from the server.:

at org.jivesoftware.smack.RosterGroup.addEntry(RosterGroup.java:196)

at com.jivesoftware.chat.components.ContactGroupTransferHandler$1.construct(Contac tGroupTransferHandler.java:217)

at com.jivesoftware.util.SwingWorker$2.run(SwingWorker.java:115)

at java.lang.Thread.run(Unknown Source)

Exception occurred during event dispatching:

java.lang.IllegalStateException: Not connected to server.

at org.jivesoftware.smack.XMPPConnection.sendPacket(XMPPConnection.java:672)

at org.jivesoftware.smack.RosterGroup.removeEntry(RosterGroup.java:231)

at com.jivesoftware.chat.components.ContactGroupTransferHandler.removeContactItem( ContactGroupTransferHandler.java:259)

at com.jivesoftware.chat.components.ContactGroupTransferHandler$1.finished(Contact GroupTransferHandler.java:228)

at com.jivesoftware.util.SwingWorker$2$1.run(SwingWorker.java:122)

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.Dialog$1.run(Unknown Source)

at java.awt.Dialog.show(Unknown Source)

at javax.swing.JOptionPane.showOptionDialog(Unknown Source)

at javax.swing.JOptionPane.showConfirmDialog(Unknown Source)

at javax.swing.JOptionPane.showConfirmDialog(Unknown Source)

at javax.swing.JOptionPane.showConfirmDialog(Unknown Source)

at com.jivesoftware.managers.SessionManager$1.run(SessionManager.java:134)

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Message was edited by:

azink

I think the problem is actually in the Smack library. I had the same problem recently while developing my own Jabber client using the Smack library. Since Spark is also built on Smack, I think it would be nice to include the fix in Smack itself :). It looks like the issue was brought up about a year ago in the Smack forum, but perhaps it slipped through the cracks. The relevant thread is here:

http://www.jivesoftware.org/community/thread.jspa?messageID=89726

After looking at the Smack source code, it seems like the fix mentioned in that thread was never added.

Chris

Cool, good to know. Is there a tracker issue created for this?

This doesn’'t apply particularly to Spark but if you are developing using Smack there is a function that will escape illegal XML characters for you:

StringUtils#escapeForXML(java.lang.String)

I think when I had looked into the issue several weeks ago the XMLPullParser automagically unescapes the XML so you don’'t have to worry about it when it comes from the server.

Alex

Since we are releasing Spark 1.0.2 next week, I can do a quick fix marked by SPARK-123. However, I’'ll move the fix over to smack itself for a future release.