1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-10 14:16:00 +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")) { else if (elementName.equals("show")) {
String modeText = parser.nextText(); String modeText = parser.nextText();
if (StringUtils.isNotEmpty(modeText)) {
presence.setMode(Presence.Mode.fromString(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")) { else if (elementName.equals("error")) {
presence.setError(parseError(parser)); presence.setError(parseError(parser));