It is not possible to retrieve offline messages with invalid XML characters

Description

Offline messages sent by XMPP clients usually send valid XML characters. However, XMPP libs may allow clients to send invalid XML characters. Something like this:

Chat chat = getConnection(0).createChat(getBareJID(1));
chat.sendMessage("Test \f 1");

will produce the following exception:

[org.jivesoftware.wildfire.OfflineMessageStore.getMessages(OfflineMessageStore.java:190)] Error retrieving offline messages of username: agent
org.dom4j.DocumentException: Error on line 1 of document : Character reference "&#19" is an invalid XML character. Nested exception: Character reference "&#19" 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.java:168)
at org.jivesoftware.wildfire.handler.PresenceUpdateHandler.initSession(PresenceUpdateHandler.java:212)
at org.jivesoftware.wildfire.handler.PresenceUpdateHandler.process(PresenceUpdateHandler.java:100)
at org.jivesoftware.wildfire.handler.PresenceUpdateHandler.process(PresenceUpdateHandler.java:153)
at org.jivesoftware.wildfire.PresenceRouter.handle(PresenceRouter.java:92)
at org.jivesoftware.wildfire.PresenceRouter.route(PresenceRouter.java:61)
at org.jivesoftware.wildfire.spi.PacketRouterImpl.route(PacketRouterImpl.java:75)
at org.jivesoftware.wildfire.net.SocketReader.processPresence(SocketReader.java:296)
at org.jivesoftware.wildfire.net.ClientSocketReader.processPresence(ClientSocketReader.java:57)

Environment

None
Fixed

Assignee

Gaston Dombiak

Reporter

Gaston Dombiak