From 229653af3017e32141dcbe0a53abe6573b0c2df9 Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Tue, 27 Nov 2018 18:27:10 +0100 Subject: [PATCH 1/3] ParserUtils: fix boolean parser How could this even happen? Signed-off-by: Georg Lukas --- .../src/main/java/org/jivesoftware/smack/util/ParserUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java index 28440bdbd..5c516f51a 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java @@ -141,7 +141,7 @@ public class ParserUtils { if (valueString == null) return null; valueString = valueString.toLowerCase(Locale.US); - return valueString.equals("true") || valueString.equals("0"); + return valueString.equals("true") || valueString.equals("1"); } public static boolean getBooleanAttribute(XmlPullParser parser, String name, From 8b88f9cb20b86f302c91684d8cd73823599b703d Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Tue, 27 Nov 2018 18:33:39 +0100 Subject: [PATCH 2/3] Bookmarks: use proper boolean parser for `autojoin` Some clients (read: Gajim) store boolean values as `0` and `1` instead of `false` and `true`, which is legal for the XML boolean type. Signed-off-by: Georg Lukas --- .../java/org/jivesoftware/smackx/bookmarks/Bookmarks.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/Bookmarks.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/Bookmarks.java index 322d0c8bb..f89e40f49 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/Bookmarks.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/Bookmarks.java @@ -269,12 +269,12 @@ public class Bookmarks implements PrivateData { private static BookmarkedConference getConferenceStorage(XmlPullParser parser) throws XmlPullParserException, IOException { String name = parser.getAttributeValue("", "name"); - String autojoin = parser.getAttributeValue("", "autojoin"); + boolean autojoin = ParserUtils.getBooleanAttribute(parser, "autojoin", false); EntityBareJid jid = ParserUtils.getBareJidAttribute(parser); BookmarkedConference conf = new BookmarkedConference(jid); conf.setName(name); - conf.setAutoJoin(Boolean.valueOf(autojoin)); + conf.setAutoJoin(autojoin); // Check for nickname boolean done = false; From b8bd10b0562810b8abc14a92c8aa8cb01abc9dc7 Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Tue, 27 Nov 2018 18:33:39 +0100 Subject: [PATCH 3/3] RoomInfo: use proper boolean parser for `muc#roominfo_subjectmod` XML allows both false/true and 0/1 syntax for booleans. Signed-off-by: Georg Lukas --- .../src/main/java/org/jivesoftware/smackx/muc/RoomInfo.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/RoomInfo.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/RoomInfo.java index b31f5bb4f..421f957f4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/RoomInfo.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/RoomInfo.java @@ -207,7 +207,8 @@ public class RoomInfo { FormField subjectmodField = form.getField("muc#roominfo_subjectmod"); if (subjectmodField != null && !subjectmodField.getValues().isEmpty()) { - subjectmod = Boolean.valueOf(subjectmodField.getFirstValue()); + String firstValue = subjectmodField.getFirstValue(); + subjectmod = ("true".equals(firstValue) || "1".equals(firstValue)); } FormField urlField = form.getField("muc#roominfo_logs");