check if jid was valid before parsing muc status or event msgs
This commit is contained in:
parent
3011f875eb
commit
d0c88e6293
|
@ -303,7 +303,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
Log.e(Config.LOGTAG, account.getJid().asBareJid() + ": received groupchat (" + from + ") message on regular MAM request. skipping");
|
Log.e(Config.LOGTAG, account.getJid().asBareJid() + ": received groupchat (" + from + ") message on regular MAM request. skipping");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean isMucStatusMessage = from.isBareJid() && mucUserElement != null && mucUserElement.hasChild("status");
|
boolean isMucStatusMessage = InvalidJid.hasValidFrom(packet) && from.isBareJid() && mucUserElement != null && mucUserElement.hasChild("status");
|
||||||
boolean selfAddressed;
|
boolean selfAddressed;
|
||||||
if (packet.fromAccount(account)) {
|
if (packet.fromAccount(account)) {
|
||||||
status = Message.STATUS_SEND;
|
status = Message.STATUS_SEND;
|
||||||
|
@ -645,7 +645,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (conversation != null && mucUserElement != null && from.isBareJid()) {
|
if (conversation != null && mucUserElement != null && InvalidJid.hasValidFrom(packet) && from.isBareJid()) {
|
||||||
for (Element child : mucUserElement.getChildren()) {
|
for (Element child : mucUserElement.getChildren()) {
|
||||||
if ("status".equals(child.getName())) {
|
if ("status".equals(child.getName())) {
|
||||||
try {
|
try {
|
||||||
|
@ -746,12 +746,12 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
}
|
}
|
||||||
|
|
||||||
Element event = original.findChild("event", "http://jabber.org/protocol/pubsub#event");
|
Element event = original.findChild("event", "http://jabber.org/protocol/pubsub#event");
|
||||||
if (event != null) {
|
if (event != null && InvalidJid.hasValidFrom(original)) {
|
||||||
parseEvent(event, original.getFrom(), account);
|
parseEvent(event, original.getFrom(), account);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String nick = packet.findChildContent("nick", Namespace.NICK);
|
final String nick = packet.findChildContent("nick", Namespace.NICK);
|
||||||
if (nick != null) {
|
if (nick != null && InvalidJid.hasValidFrom(original)) {
|
||||||
Contact contact = account.getRoster().getContact(from);
|
Contact contact = account.getRoster().getContact(from);
|
||||||
if (contact.setPresenceName(nick)) {
|
if (contact.setPresenceName(nick)) {
|
||||||
mXmppConnectionService.getAvatarService().clear(contact);
|
mXmppConnectionService.getAvatarService().clear(contact);
|
||||||
|
|
|
@ -31,6 +31,7 @@ package eu.siacs.conversations.xmpp;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.xmpp.stanzas.AbstractStanza;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
public class InvalidJid implements Jid {
|
public class InvalidJid implements Jid {
|
||||||
|
@ -140,10 +141,19 @@ public class InvalidJid implements Jid {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isValid(Jid jid) {
|
public static boolean isValid(Jid jid) {
|
||||||
if (jid != null && jid instanceof InvalidJid) {
|
return !(jid != null && jid instanceof InvalidJid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasValidFrom(AbstractStanza stanza) {
|
||||||
|
final String from = stanza.getAttribute("from");
|
||||||
|
if (from == null) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
}
|
||||||
|
try {
|
||||||
|
Jid.ofEscaped(from);
|
||||||
return true;
|
return true;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue