powered by Jive Software

Exploding PacketReader

Hi Matt,

One client version I’'ve played with (Just Another Jabber Client) allows users to send formatted message. It embeds 2 body versions in the message, an XHTML version and a normal text version. The presence of the XHTML blows up PacketReader:

org.xmlpull.v1.XmlPullParserException: parser must be on START_TAG or TEXT to read text (position: START_TAG seen …y><span style=’‘font-family: Tahoma;font-size: 10;color: #000000;’’>… @1:4964)

at org.xmlpull.mxp1.MXParser.nextText(MXParser.java:1115)

at org.jivesoftware.smack.PacketReader.parseMessage(PacketReader.java:706)

at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:335)

at org.jivesoftware.smack.PacketReader.access$0(PacketReader.java:329)

at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:195)

Here’'s a sample message:


Don’‘t know how legitimate that is but here’'s a quick diff patch to ignore unknown tags:

Index: PacketReader.java


RCS file: /media/cvs/smack-May-01-2003/source/org/jivesoftware/smack/PacketReader.java,v

retrieving revision 1.1

diff -r1.1 PacketReader.java


String ignoreTag = null;


< if (eventType == XmlPullParser.START_TAG) {

if (ignoreTag == null && eventType == XmlPullParser.START_TAG) {


} else {

ignoreTag = parser.getName();


} else if (parser.getName().equals(ignoreTag)) {

ignoreTag = null;

Seems to not cause problems but YMMV

Take care,



Thanks for the bug report and fix. I’'ll actually be changing the parsing logic a bit to handle arbitrary packet extensions (like html formatting) so that should fix the issue too.



Hi Matt,

Just as a FYI his problem has moved to a new spot (this is on the May20 build:

org.xmlpull.v1.XmlPullParserException: parser must be on START_TAG or TEXT to read text (position: START_TAG seen …family: MS Serif; color: #; margin:0; padding:0; font-size: 10pt’’>… @1:13459)

at org.xmlpull.mxp1.MXParser.nextText(MXParser.java:1115)

at org.jivesoftware.smack.PacketReader.parsePacketExtension(PacketReader.java:745)

at org.jivesoftware.smack.PacketReader.parseMessage(PacketReader.java:631)

at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:242)

at org.jivesoftware.smack.PacketReader.access$0(PacketReader.java:236)

at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:102)

The particular XML that did this:

<message to=’‘insurgent@werewolf’’ from=’‘surge357%hotmail.com@msn.localhost’’ type=’‘chat’’>Hy24p0test3<html xmlns=’‘http://www.w3.org/1999/xhtml’’>

<span style=’‘font-family: MS Serif; color: #; margin:0; padding:0; font-size: 10pt’’>test3<x xmlns=’‘jabber:x:event’’>

Take care,



I think that I just solved this problem too now. It should be in tomorrow’'s daily builds.



Neat! I think you posted your reply before I even posted the issue


Not quite, but I get email updates on posts so can make replies pretty fast.