more npe checks in muc packet parser

This commit is contained in:
iNPUTmice 2014-11-13 14:27:10 +01:00
parent 61f046a675
commit 77ba68d61f
1 changed files with 35 additions and 32 deletions

View File

@ -151,9 +151,10 @@ public class MucOptions {
String type = packet.getAttribute("type"); String type = packet.getAttribute("type");
if (type == null) { if (type == null) {
User user = new User(); User user = new User();
Element item = packet.findChild("x", Element x = packet.findChild("x","http://jabber.org/protocol/muc#user");
"http://jabber.org/protocol/muc#user") if (x != null) {
.findChild("item"); Element item = x.findChild("item");
if (item != null) {
user.setName(name); user.setName(name);
user.setAffiliation(item.getAttribute("affiliation")); user.setAffiliation(item.getAttribute("affiliation"));
user.setRole(item.getAttribute("role")); user.setRole(item.getAttribute("role"));
@ -173,8 +174,8 @@ public class MucOptions {
addUser(user); addUser(user);
} }
if (pgp != null) { if (pgp != null) {
Element x = packet.findChild("x", "jabber:x:signed"); Element signed = packet.findChild("x", "jabber:x:signed");
if (x != null) { if (signed != null) {
Element status = packet.findChild("status"); Element status = packet.findChild("status");
String msg; String msg;
if (status != null) { if (status != null) {
@ -183,7 +184,9 @@ public class MucOptions {
msg = ""; msg = "";
} }
user.setPgpKeyId(pgp.fetchKeyId(account, msg, user.setPgpKeyId(pgp.fetchKeyId(account, msg,
x.getContent())); signed.getContent()));
}
}
} }
} }
} else if (type.equals("unavailable") && name.equals(this.joinnick)) { } else if (type.equals("unavailable") && name.equals(this.joinnick)) {