Return empty set on invalid PEP devicelist
This commit is contained in:
parent
25450bf6d3
commit
6867b5c3ab
|
@ -1,5 +1,6 @@
|
||||||
package eu.siacs.conversations.crypto.axolotl;
|
package eu.siacs.conversations.crypto.axolotl;
|
||||||
|
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -638,7 +639,7 @@ public class AxolotlService {
|
||||||
return ownDeviceId;
|
return ownDeviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerDevices(final Jid jid, final Set<Integer> deviceIds) {
|
public void registerDevices(final Jid jid, @NonNull final Set<Integer> deviceIds) {
|
||||||
for(Integer i:deviceIds) {
|
for(Integer i:deviceIds) {
|
||||||
Log.d(Config.LOGTAG, "Adding Device ID:"+ jid + ":"+i);
|
Log.d(Config.LOGTAG, "Adding Device ID:"+ jid + ":"+i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.siacs.conversations.parser;
|
package eu.siacs.conversations.parser;
|
||||||
|
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
@ -96,26 +97,25 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
|
||||||
return items.findChild("item");
|
return items.findChild("item");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public Set<Integer> deviceIds(final Element item) {
|
public Set<Integer> deviceIds(final Element item) {
|
||||||
Set<Integer> deviceIds = new HashSet<>();
|
Set<Integer> deviceIds = new HashSet<>();
|
||||||
if (item == null) {
|
if (item != null) {
|
||||||
return null;
|
final Element list = item.findChild("list");
|
||||||
}
|
if (list != null) {
|
||||||
final Element list = item.findChild("list");
|
for (Element device : list.getChildren()) {
|
||||||
if(list == null) {
|
if (!device.getName().equals("device")) {
|
||||||
return null;
|
continue;
|
||||||
}
|
}
|
||||||
for(Element device : list.getChildren()) {
|
try {
|
||||||
if(!device.getName().equals("device")) {
|
Integer id = Integer.valueOf(device.getAttribute("id"));
|
||||||
continue;
|
deviceIds.add(id);
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
try {
|
Log.e(Config.LOGTAG, "Encountered nvalid <device> node in PEP:" + device.toString()
|
||||||
Integer id = Integer.valueOf(device.getAttribute("id"));
|
+ ", skipping...");
|
||||||
deviceIds.add(id);
|
continue;
|
||||||
} catch (NumberFormatException e) {
|
}
|
||||||
Log.e(Config.LOGTAG, "Encountered nvalid <device> node in PEP:" + device.toString()
|
}
|
||||||
+ ", skipping...");
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return deviceIds;
|
return deviceIds;
|
||||||
|
|
Loading…
Reference in a new issue