1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-29 17:52:06 +01:00

Make presence parsing more robust

by allowing 'show' to be an empty element: '<show />'
This commit is contained in:
Florian Schmaus 2014-08-28 14:14:18 +02:00
parent 218dc66cf7
commit 5a5524623c

View file

@ -439,7 +439,18 @@ public class PacketParserUtils {
}
else if (elementName.equals("show")) {
String modeText = parser.nextText();
presence.setMode(Presence.Mode.fromString(modeText));
if (StringUtils.isNotEmpty(modeText)) {
presence.setMode(Presence.Mode.fromString(modeText));
} else {
// Some implementations send presence stanzas with a
// '<show />' element, which is a invalid XMPP presence
// stanza according to RFC 6121 4.7.2.1
LOGGER.warning("Empty or null mode text in presence show element form "
+ presence.getFrom()
+ " with id '"
+ presence.getPacketID()
+ "' which is invalid according to RFC6121 4.7.2.1");
}
}
else if (elementName.equals("error")) {
presence.setError(parseError(parser));