Skip to content

Commit

Permalink
Make presence parsing more robust
Browse files Browse the repository at this point in the history
by allowing 'show' to be an empty element: '<show />'
  • Loading branch information
Flowdalic committed Aug 28, 2014
1 parent 218dc66 commit 5a55246
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,18 @@ else if (elementName.equals("priority")) {
}
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));
Expand Down

0 comments on commit 5a55246

Please sign in to comment.