Luca5
January 23, 2017, 7:40am
1
With Smack 4.2.0-rc2, when PacketParserUtils.parseMessage receives a packet with a chatestate such as :
<message from=‘test1@test.chat/My-Mac-Pro’
xmlns=‘jabber:client’ xml:lang=‘en’ type=‘chat’ to=‘test2@test.chat’ id=‘aacba’>
Test
<active
xmlns=‘http://jabber.org/protocol/chatstates ’/>
A IllegalStateException("Invalid Stanza: Must not contain text or mixed content as direct child of ") is thrown here:
public static Message parseMessage(XmlPullParser parser){
…
int eventType = parser.next();
switch (eventType) {
case XmlPullParser.START_TAG:
String elementName = parser.getName();
String namespace = parser.getNamespace();
switch(elementName) {
…
case XmlPullParser.TEXT:
throw new IllegalStateException("Invalid Stanza: Must not contain text or mixed content as direct child of ");
}
}
}
Am I missing something in smack 4.2 to be able to handle messages with chat state? Or is this a bug?
Flow
January 23, 2017, 8:25am
2
<message from=‘test1@test.chat/My-Mac-Pro’
xmlns=‘jabber:client’ xml:lang=‘en’ type=‘chat’ to=‘test2@test.chat’ id=‘aacba’>
Test
<active
xmlns=‘http://jabber.org/protocol/chatstates ’/>
Are you positive that this stanza triggers it?
Luca5
January 23, 2017, 3:18pm
3
The message is wrapped inside a Mam message. But all the other messages that are pulled down from mam without a chat state element are parsed without problem.
Flow
January 23, 2017, 4:31pm
4
Please show the complete stanza.
Luca5
January 23, 2017, 5:29pm
5
Full message stanza :
<message from='test1@test.chat' to='test1@test.chat/Android-51022b787fb44d76'><result queryid='89532d30-d2d1-4437-91b1-fef93e91de00' xmlns='urn:xmpp:mam:1' id='AESBQLFD89G1'><forwarded xmlns='urn:xmpp:forward:0'><delay xmlns='urn:xmpp:delay' from='test2@test.chat/My-Mac-Pro' stamp='2016-09-02T20:04:09Z'></delay><message from='test2@test.chat/My-Mac-Pro' xmlns='jabber:client' xml:lang='en' type='chat' to='test1@test.chat' id='aacba'>
<body>test</body>
<active xmlns='http://jabber.org/protocol/chatstates'/>
</message></forwarded></result><delay xmlns='urn:xmpp:delay' from='atlas.chat' stamp='2017-01-23T05:42:54.923769Z'>Offline Storage</delay></message>
We have the same issue on Smack 4.2.0-rc2.
Our analysis is, it is caused by messages sent by a clients that formats its XML-messages. Also its very easy to replicate.
Use the EnhancedDebugger, Copy a message from the ‘All packets’ tab, this is nicely formatted to make it readable, Paste this message in the ‘Ad hoc message’, press Send and see your client halt with the mentioned exception.
text
It applies for messages and presences.
Flow
January 24, 2017, 7:38pm
7
Please try the latest 4.2.0-rc3-SNAPSHOT and report back if it fixes the issue. Thank you.
And for me! (@Luca You may set the question to answered now)