Skip to content

Commit

Permalink
XEP-0048 defines an optional nickname for a bookmarked conference roo…
Browse files Browse the repository at this point in the history
…m, using an element named 'nick'.

Some clients have been observed to include an empty 'nick' element (instead of no such element) when a nickname is not stored as part of the bookmark.

Smack should not fail to parse these elements. Without the change in this commit, it fails with the following exception:

```
org.jxmpp.stringprep.XmppStringprepException: Argument can't be the empty string
    at org.jxmpp.stringprep.XmppStringPrepUtil.throwIfEmptyString(XmppStringPrepUtil.java:131)
    at org.jxmpp.stringprep.XmppStringPrepUtil.resourceprep(XmppStringPrepUtil.java:101)
    at org.jxmpp.jid.parts.Resourcepart.from(Resourcepart.java:91)
    at org.jivesoftware.smackx.bookmarks.Bookmarks.getConferenceStorage(Bookmarks.java:285)
    ...
```
  • Loading branch information
guusdk committed Jul 14, 2021
1 parent c9af25c commit ad30fae
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ private static BookmarkedConference getConferenceStorage(XmlPullParser parser) t
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT && "nick".equals(parser.getName())) {
String nickString = parser.nextText();
conf.setNickname(Resourcepart.from(nickString));
if (nickString != null && !nickString.isEmpty()) {
conf.setNickname(Resourcepart.from(nickString));
}
}
else if (eventType == XmlPullParser.Event.START_ELEMENT && "password".equals(parser.getName())) {
conf.setPassword(parser.nextText());
Expand Down

0 comments on commit ad30fae

Please sign in to comment.