From 5a5524623cc70838dce3e88d87a374cd9a31453b Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 28 Aug 2014 14:14:18 +0200 Subject: [PATCH] Make presence parsing more robust by allowing 'show' to be an empty element: '' --- .../jivesoftware/smack/util/PacketParserUtils.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java index 968442840..c15956ef8 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java @@ -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 + // '' 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));