Bug when storing offline messages with \1 char

Hi,

When you send a message containing a \1 char to someone who is offline, this gets stored in the jiveoffline table.

When that person comes online, the way it is stored makes the XML parser fail and the messages never gets delivered to that guy.

Let me show you :

I send the message this way :

echo -ne “test \0001 test” | sendxmpp -t gmsoft@jabber.tuxicoman.be

I get this in the postgres database :

username | message


±—


gmsoft |

The � atom gets parsed by the xml parser when this message is retrieved. Then you see the following error in the logs :

2006.04.23 19:51:14 org.jivesoftware.wildfire.OfflineMessageStore.getMessages(OfflineMessageStore.ja va:192) Error retrieving offline messages of username: gmsoft

org.dom4j.DocumentException: Error on line 1 of document : Character reference “&#1” is an invalid XML character. Nested exception: Character reference “&#1” is an invalid XML character.

at org.dom4j.io.SAXReader.read(SAXReader.java:482)

at org.dom4j.io.SAXReader.read(SAXReader.java:365)

at org.jivesoftware.wildfire.OfflineMessageStore.getMessages(OfflineMessageStore.j ava:171)

at org.jivesoftware.wildfire.handler.PresenceUpdateHandler.initSession(PresenceUpd ateHandler.java:212)

at org.jivesoftware.wildfire.handler.PresenceUpdateHandler.process(PresenceUpdateH andler.java:100)

at org.jivesoftware.wildfire.handler.PresenceUpdateHandler.process(PresenceUpdateH andler.java:153)

at org.jivesoftware.wildfire.PresenceRouter.handle(PresenceRouter.java:92)

at org.jivesoftware.wildfire.PresenceRouter.route(PresenceRouter.java:61)

at org.jivesoftware.wildfire.PacketRouter.route(PacketRouter.java:73)

at org.jivesoftware.wildfire.net.SocketReader.processPresence(SocketReader.java:44 5)

at org.jivesoftware.wildfire.net.ClientSocketReader.processPresence(ClientSocketRe ader.java:56)

at org.jivesoftware.wildfire.net.SocketReader.readStream(SocketReader.java:242)

at org.jivesoftware.wildfire.net.SocketReader.run(SocketReader.java:119)

at java.lang.Thread.run(Thread.java:595)

Nested exception:

org.xml.sax.SAXParseException: Character reference “&#1” is an invalid XML character.

at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseExcep tion(ErrorHandlerWrapper.java:236)

at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHan dlerWrapper.java:215)

at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorRe porter.java:386)

at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorRe porter.java:316)

at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner. java:1438)

at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanCharReferenceValue(XMLSc anner.java:1304)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanChar Reference(XMLDocumentFragmentScannerImpl.java:1259)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$Fragment ContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1753)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocu ment(XMLDocumentFragmentScannerImpl.java:368)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Config uration.java:834)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Config uration.java:764)

at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)

at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXP arser.java:1242)

at org.dom4j.io.SAXReader.read(SAXReader.java:465)

at org.dom4j.io.SAXReader.read(SAXReader.java:365)

at org.jivesoftware.wildfire.OfflineMessageStore.getMessages(OfflineMessageStore.j ava:171)

at org.jivesoftware.wildfire.handler.PresenceUpdateHandler.initSession(PresenceUpd ateHandler.java:212)

at org.jivesoftware.wildfire.handler.PresenceUpdateHandler.process(PresenceUpdateH andler.java:100)

at org.jivesoftware.wildfire.handler.PresenceUpdateHandler.process(PresenceUpdateH andler.java:153)

at org.jivesoftware.wildfire.PresenceRouter.handle(PresenceRouter.java:92)

at org.jivesoftware.wildfire.PresenceRouter.route(PresenceRouter.java:61)

at org.jivesoftware.wildfire.PacketRouter.route(PacketRouter.java:73)

at org.jivesoftware.wildfire.net.SocketReader.processPresence(SocketReader.java:44 5)

at org.jivesoftware.wildfire.net.ClientSocketReader.processPresence(ClientSocketRe ader.java:56)

at org.jivesoftware.wildfire.net.SocketReader.readStream(SocketReader.java:242)

at org.jivesoftware.wildfire.net.SocketReader.run(SocketReader.java:119)

at java.lang.Thread.run(Thread.java:595)

And the message never gets delivered. Also, the other previous messages received while this person was offline are delivered again and again upon each connection. This is really annoying.

If I send such message while beeing online, I correctly receive it.

I don’'t know what is the best way to fix this.

I would go for fixing the XML parser as if this XML entry is wrong, it should not fail and simply return it. However it should

I’'m running wildfire 2.6.1 with Sun JDK 1.5.0.06 on a Gentoo Linux using the precompiled binaries from the official site.

I’'m using postgresql 8.0.4 and the database is correctly created with the unicode charset.

Let me know if you need more info to troubleshoot this issue.

Hi,

updating to Wifi 2.6.2 will not solve the problem, so deleting \1 out of the database seems currently to be the only solution. It should be easy to modify OfflineMessageStore.java to handle the exception in a much better way.

Fixing the XML parser is imho also necessary.

LG

just a small update. I’'m using the embedded database, there unicode characters like \1 are normally stored as “\u0001” but Wifi does insert “&#1”. But also if I modify “&#1” to “\u0001” and restart Wifi the messages can not be delivered, I get then this error: “An invalid XML character (Unicode: 0x1) was found in the element content of the document.”