diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java index 32946f486..954c92328 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java @@ -701,6 +701,7 @@ abstract public class Node { private final String firstElement; private final String secondElement; + private final boolean allowEmpty; EventContentFilter(String elementName) { @@ -711,6 +712,8 @@ abstract public class Node { firstElement = firstLevelEelement; secondElement = secondLevelElement; + allowEmpty = firstElement.equals(EventElementType.items.toString()) + && "item".equals(secondLevelElement); } public boolean acceptSpecific(Message message) { @@ -736,6 +739,13 @@ abstract public class Node { List secondLevelList = ((EmbeddedPacketExtension)embedEvent).getExtensions(); + // XEP-0060 allows no elements on second level for notifications. See schema or + // for example ยง 4.3: + // "although event notifications MUST include an empty element;" + if (allowEmpty && secondLevelList.isEmpty()) { + return true; + } + if (secondLevelList.size() > 0 && secondLevelList.get(0).getElementName().equals(secondElement)) return true; }