From 1e5f0eb749bfd24fd09c2a48932b7c6f9658757b Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 20 Aug 2014 15:23:52 +0200 Subject: [PATCH] Make parseElementText handle empty string elements ie. elements which only content is the empty string, for example . Fixes SMACK-598 --- .../jivesoftware/smack/util/PacketParserUtils.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 28be0b191..f6df91214 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 @@ -182,8 +182,17 @@ public class PacketParserUtils { // Advance to the text of the Element int event = parser.next(); if (event != XmlPullParser.TEXT) { - throw new XmlPullParserException( - "Non-empty element tag not followed by text, while Mixed Content (XML 3.2.2) is disallowed"); + if (event == XmlPullParser.END_TAG) { + // Assume this is the end tag of the start tag at the + // beginning of this method. Typical examples where this + // happens are body elements containing the empty string, + // ie. , which appears to be valid XMPP, or a + // least it's not explicitly forbidden by RFC 6121 5.2.3 + return ""; + } else { + throw new XmlPullParserException( + "Non-empty element tag not followed by text, while Mixed Content (XML 3.2.2) is disallowed"); + } } res = parser.getText(); event = parser.next();