mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 13:32:07 +01:00
Do not call XmlPullParser.getName() when the event is unknown
XmlPullParser.getName() only returns a result if the current parser event is START_ELEMENT or END_ELEMENT. If this is not the case, then the method may throw (if StAX is used).
This commit is contained in:
parent
4120b42761
commit
5eef31e49c
25 changed files with 74 additions and 90 deletions
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2016-2019 Florian Schmaus
|
||||
* Copyright © 2016-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -39,9 +39,9 @@ public class IoTSetRequestProvider extends IQProvider<IoTSetRequest> {
|
|||
List<SetData> data = new ArrayList<>(4);
|
||||
outerloop: while (true) {
|
||||
final XmlPullParser.Event eventType = parser.next();
|
||||
final String name = parser.getName();
|
||||
switch (eventType) {
|
||||
case START_ELEMENT:
|
||||
final String name = parser.getName();
|
||||
switch (name) {
|
||||
case "bool": {
|
||||
String valueName = parser.getAttributeValue(null, "name");
|
||||
|
|
|
@ -110,9 +110,9 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
|
|||
List<IoTDataField> fields = new ArrayList<>();
|
||||
outerloop: while (true) {
|
||||
final XmlPullParser.Event eventType = parser.next();
|
||||
final String name = parser.getName();
|
||||
switch (eventType) {
|
||||
case START_ELEMENT:
|
||||
final String name = parser.getName();
|
||||
IoTDataField field = null;
|
||||
final String fieldName = parser.getAttributeValue(null, "name");
|
||||
final String fieldValue = parser.getAttributeValue(null, "value");
|
||||
|
|
|
@ -59,9 +59,9 @@ public class MamPrefsIQProvider extends IQProvider<MamPrefsIQ> {
|
|||
|
||||
outerloop: while (true) {
|
||||
final XmlPullParser.Event eventType = parser.next();
|
||||
final String name = parser.getName();
|
||||
switch (eventType) {
|
||||
case START_ELEMENT:
|
||||
final String name = parser.getName();
|
||||
switch (name) {
|
||||
case "always":
|
||||
alwaysJids = iterateJids(parser);
|
||||
|
@ -92,9 +92,9 @@ public class MamPrefsIQProvider extends IQProvider<MamPrefsIQ> {
|
|||
|
||||
outerloop: while (true) {
|
||||
final XmlPullParser.Event eventType = parser.next();
|
||||
final String name = parser.getName();
|
||||
switch (eventType) {
|
||||
case START_ELEMENT:
|
||||
final String name = parser.getName();
|
||||
switch (name) {
|
||||
case "jid":
|
||||
parser.next();
|
||||
|
|
|
@ -47,10 +47,10 @@ public class MamQueryIQProvider extends IQProvider<MamQueryIQ> {
|
|||
|
||||
outerloop: while (true) {
|
||||
final XmlPullParser.Event eventType = parser.next();
|
||||
final String name = parser.getName();
|
||||
|
||||
switch (eventType) {
|
||||
case START_ELEMENT:
|
||||
final String name = parser.getName();
|
||||
switch (name) {
|
||||
case DataForm.ELEMENT:
|
||||
dataForm = DataFormProvider.INSTANCE.parse(parser);
|
||||
|
|
|
@ -49,9 +49,9 @@ public class MamResultProvider extends ExtensionElementProvider<MamResultExtensi
|
|||
|
||||
outerloop: while (true) {
|
||||
final XmlPullParser.Event eventType = parser.next();
|
||||
final String name = parser.getName();
|
||||
switch (eventType) {
|
||||
case START_ELEMENT:
|
||||
final String name = parser.getName();
|
||||
switch (name) {
|
||||
case Forwarded.ELEMENT:
|
||||
forwarded = ForwardedProvider.parseForwardedMessage(parser, xmlEnvironment);
|
||||
|
|
|
@ -50,10 +50,11 @@ public class MarkupElementProvider extends ExtensionElementProvider<MarkupElemen
|
|||
|
||||
while (true) {
|
||||
XmlPullParser.Event tag = parser.next();
|
||||
String name = parser.getName();
|
||||
String name;
|
||||
int start, end;
|
||||
switch (tag) {
|
||||
case START_ELEMENT:
|
||||
name = parser.getName();
|
||||
switch (name) {
|
||||
case BlockQuoteElement.ELEMENT:
|
||||
start = ParserUtils.getIntegerAttributeOrThrow(parser, MarkupChildElement.ATTR_START,
|
||||
|
@ -108,6 +109,11 @@ public class MarkupElementProvider extends ExtensionElementProvider<MarkupElemen
|
|||
break;
|
||||
|
||||
case END_ELEMENT:
|
||||
if (parser.getDepth() == initialDepth) {
|
||||
return markup.build();
|
||||
}
|
||||
|
||||
name = parser.getName();
|
||||
switch (name) {
|
||||
case SpanElement.ELEMENT:
|
||||
markup.addSpan(spanStart, spanEnd, spanStyles);
|
||||
|
@ -128,9 +134,6 @@ public class MarkupElementProvider extends ExtensionElementProvider<MarkupElemen
|
|||
}
|
||||
listBuilder.endList();
|
||||
break;
|
||||
|
||||
case MarkupElement.ELEMENT:
|
||||
return markup.build();
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ public class BytestreamsProvider extends IQProvider<Bytestream> {
|
|||
String elementName;
|
||||
while (!done) {
|
||||
eventType = parser.next();
|
||||
elementName = parser.getName();
|
||||
if (eventType == XmlPullParser.Event.START_ELEMENT) {
|
||||
elementName = parser.getName();
|
||||
if (elementName.equals(Bytestream.StreamHost.ELEMENT)) {
|
||||
JID = ParserUtils.getJidAttribute(parser);
|
||||
host = parser.getAttributeValue("", "host");
|
||||
|
@ -70,6 +70,7 @@ public class BytestreamsProvider extends IQProvider<Bytestream> {
|
|||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.Event.END_ELEMENT) {
|
||||
elementName = parser.getName();
|
||||
if (elementName.equals("streamhost")) {
|
||||
if (port == null) {
|
||||
toReturn.addStreamHost(JID, host);
|
||||
|
|
|
@ -78,9 +78,9 @@ public class AdHocCommandDataProvider extends IQProvider<AdHocCommandData> {
|
|||
}
|
||||
while (!done) {
|
||||
eventType = parser.next();
|
||||
elementName = parser.getName();
|
||||
namespace = parser.getNamespace();
|
||||
if (eventType == XmlPullParser.Event.START_ELEMENT) {
|
||||
elementName = parser.getName();
|
||||
if (parser.getName().equals("actions")) {
|
||||
String execute = parser.getAttributeValue("", "execute");
|
||||
if (execute != null) {
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.jivesoftware.smack.packet.XmlEnvironment;
|
|||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransportCandidate;
|
||||
import org.jivesoftware.smackx.jingle.provider.JingleContentTransportProvider;
|
||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport;
|
||||
|
@ -62,9 +61,9 @@ public class JingleS5BTransportProvider extends JingleContentTransportProvider<J
|
|||
JingleS5BTransportCandidate.Builder cb;
|
||||
outerloop: while (true) {
|
||||
XmlPullParser.TagEvent tag = parser.nextTag();
|
||||
String name = parser.getName();
|
||||
switch (tag) {
|
||||
case START_ELEMENT: {
|
||||
String name = parser.getName();
|
||||
switch (name) {
|
||||
|
||||
case JingleContentTransportCandidate.ELEMENT:
|
||||
|
@ -110,8 +109,7 @@ public class JingleS5BTransportProvider extends JingleContentTransportProvider<J
|
|||
break;
|
||||
|
||||
case END_ELEMENT: {
|
||||
switch (name) {
|
||||
case JingleContentTransport.ELEMENT:
|
||||
if (parser.getDepth() == initialDepth) {
|
||||
break outerloop;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,11 +45,11 @@ public class MoodProvider extends ExtensionElementProvider<MoodElement> {
|
|||
|
||||
outerloop: while (true) {
|
||||
XmlPullParser.Event tag = parser.next();
|
||||
String name = parser.getName();
|
||||
String namespace = parser.getNamespace();
|
||||
|
||||
switch (tag) {
|
||||
case START_ELEMENT:
|
||||
String name = parser.getName();
|
||||
String namespace = parser.getNamespace();
|
||||
if (MoodElement.ELEM_TEXT.equals(name)) {
|
||||
text = parser.nextText();
|
||||
continue outerloop;
|
||||
|
@ -74,7 +74,7 @@ public class MoodProvider extends ExtensionElementProvider<MoodElement> {
|
|||
}
|
||||
|
||||
case END_ELEMENT:
|
||||
if (MoodElement.ELEMENT.equals(name)) {
|
||||
if (MoodElement.ELEMENT.equals(parser.getName())) {
|
||||
MoodElement.MoodSubjectElement subjectElement = (mood == null && concretisation == null) ?
|
||||
null : new MoodElement.MoodSubjectElement(mood, concretisation);
|
||||
return new MoodElement(subjectElement, text);
|
||||
|
|
|
@ -46,8 +46,6 @@ public class StreamInitiationProvider extends IQProvider<StreamInitiation> {
|
|||
|
||||
@Override
|
||||
public StreamInitiation parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
boolean done = false;
|
||||
|
||||
// si
|
||||
String id = parser.getAttributeValue("", "id");
|
||||
String mimeType = parser.getAttributeValue("", "mime-type");
|
||||
|
@ -66,13 +64,11 @@ public class StreamInitiationProvider extends IQProvider<StreamInitiation> {
|
|||
DataForm form = null;
|
||||
DataFormProvider dataFormProvider = new DataFormProvider();
|
||||
|
||||
String elementName;
|
||||
String namespace;
|
||||
while (!done) {
|
||||
outerloop: while (true) {
|
||||
XmlPullParser.Event eventType = parser.next();
|
||||
elementName = parser.getName();
|
||||
namespace = parser.getNamespace();
|
||||
if (eventType == XmlPullParser.Event.START_ELEMENT) {
|
||||
String elementName = parser.getName();
|
||||
String namespace = parser.getNamespace();
|
||||
if (elementName.equals("file")) {
|
||||
name = parser.getAttributeValue("", "name");
|
||||
size = parser.getAttributeValue("", "size");
|
||||
|
@ -87,9 +83,10 @@ public class StreamInitiationProvider extends IQProvider<StreamInitiation> {
|
|||
form = dataFormProvider.parse(parser);
|
||||
}
|
||||
} else if (eventType == XmlPullParser.Event.END_ELEMENT) {
|
||||
if (elementName.equals("si")) {
|
||||
done = true;
|
||||
} else if (elementName.equals("file")) {
|
||||
if (parser.getDepth() == initialDepth) {
|
||||
break outerloop;
|
||||
}
|
||||
if (parser.getName().equals("file")) {
|
||||
long fileSize = 0;
|
||||
if (size != null && size.trim().length() != 0) {
|
||||
try {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software, 2014-2019 Florian Schmaus
|
||||
* Copyright 2003-2007 Jive Software, 2014-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -40,8 +40,8 @@ public class XHTMLExtensionProvider extends ExtensionElementProvider<XHTMLExtens
|
|||
|
||||
while (true) {
|
||||
XmlPullParser.Event eventType = parser.getEventType();
|
||||
String name = parser.getName();
|
||||
if (eventType == XmlPullParser.Event.START_ELEMENT) {
|
||||
String name = parser.getName();
|
||||
if (name.equals(Message.BODY)) {
|
||||
xhtmlExtension.addBody(PacketParserUtils.parseElement(parser));
|
||||
}
|
||||
|
|
|
@ -340,7 +340,6 @@ public class RTPBridge extends IQ {
|
|||
boolean done = false;
|
||||
|
||||
XmlPullParser.Event eventType;
|
||||
String elementName;
|
||||
|
||||
if (!parser.getNamespace().equals(RTPBridge.NAMESPACE))
|
||||
// TODO: Should be SmackParseException.
|
||||
|
@ -356,9 +355,9 @@ public class RTPBridge extends IQ {
|
|||
// Start processing sub-elements
|
||||
while (!done) {
|
||||
eventType = parser.next();
|
||||
elementName = parser.getName();
|
||||
|
||||
if (eventType == XmlPullParser.Event.START_ELEMENT) {
|
||||
String elementName = parser.getName();
|
||||
if (elementName.equals("candidate")) {
|
||||
for (int i = 0; i < parser.getAttributeCount(); i++) {
|
||||
if (parser.getAttributeName(i).equals("ip"))
|
||||
|
|
|
@ -66,14 +66,13 @@ public abstract class JingleContentDescriptionProvider extends ExtensionElementP
|
|||
public JingleContentDescription parse(XmlPullParser parser,
|
||||
int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException,
|
||||
IOException {
|
||||
boolean done = false;
|
||||
JingleContentDescription desc = getInstance();
|
||||
|
||||
while (!done) {
|
||||
outerloop: while (true) {
|
||||
XmlPullParser.Event eventType = parser.next();
|
||||
String name = parser.getName();
|
||||
|
||||
if (eventType == XmlPullParser.Event.START_ELEMENT) {
|
||||
String name = parser.getName();
|
||||
if (name.equals(JingleContentDescription.JinglePayloadType.NODENAME)) {
|
||||
desc.addJinglePayloadType(parsePayload(parser));
|
||||
} else {
|
||||
|
@ -81,8 +80,8 @@ public abstract class JingleContentDescriptionProvider extends ExtensionElementP
|
|||
throw new IOException("Unknow element \"" + name + "\" in content.");
|
||||
}
|
||||
} else if (eventType == XmlPullParser.Event.END_ELEMENT) {
|
||||
if (name.equals(JingleContentDescription.NODENAME)) {
|
||||
done = true;
|
||||
if (parser.getDepth() == initialDepth) {
|
||||
break outerloop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,14 +65,12 @@ public abstract class JingleDescriptionProvider extends ExtensionElementProvider
|
|||
*/
|
||||
@Override
|
||||
public JingleDescription parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
JingleDescription desc = getInstance();
|
||||
|
||||
while (!done) {
|
||||
outerloop: while (true) {
|
||||
XmlPullParser.Event eventType = parser.next();
|
||||
String name = parser.getName();
|
||||
|
||||
if (eventType == XmlPullParser.Event.START_ELEMENT) {
|
||||
String name = parser.getName();
|
||||
if (name.equals(PayloadType.NODENAME)) {
|
||||
desc.addPayloadType(parsePayload(parser));
|
||||
} else {
|
||||
|
@ -80,8 +78,8 @@ public abstract class JingleDescriptionProvider extends ExtensionElementProvider
|
|||
throw new IOException("Unknow element \"" + name + "\" in content.");
|
||||
}
|
||||
} else if (eventType == XmlPullParser.Event.END_ELEMENT) {
|
||||
if (name.equals(JingleDescription.NODENAME)) {
|
||||
done = true;
|
||||
if (parser.getDepth() == initialDepth) {
|
||||
break outerloop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,10 +84,10 @@ public class JingleProvider extends IQProvider<Jingle> {
|
|||
// Start processing sub-elements
|
||||
while (!done) {
|
||||
eventType = parser.next();
|
||||
elementName = parser.getName();
|
||||
namespace = parser.getNamespace();
|
||||
|
||||
if (eventType == XmlPullParser.Event.START_ELEMENT) {
|
||||
elementName = parser.getName();
|
||||
namespace = parser.getNamespace();
|
||||
|
||||
// Parse some well know subelements, depending on the namespaces
|
||||
// and element names...
|
||||
|
|
|
@ -54,14 +54,13 @@ public abstract class JingleTransportProvider extends ExtensionElementProvider<J
|
|||
*/
|
||||
@Override
|
||||
public JingleTransport parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
JingleTransport trans = getInstance();
|
||||
|
||||
while (!done) {
|
||||
outerloop: while (true) {
|
||||
XmlPullParser.Event eventType = parser.next();
|
||||
String name = parser.getName();
|
||||
|
||||
if (eventType == XmlPullParser.Event.START_ELEMENT) {
|
||||
String name = parser.getName();
|
||||
if (name.equals(JingleTransportCandidate.NODENAME)) {
|
||||
JingleTransportCandidate jtc = parseCandidate(parser);
|
||||
if (jtc != null) trans.addCandidate(jtc);
|
||||
|
@ -72,8 +71,8 @@ public abstract class JingleTransportProvider extends ExtensionElementProvider<J
|
|||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.Event.END_ELEMENT) {
|
||||
if (name.equals(JingleTransport.NODENAME)) {
|
||||
done = true;
|
||||
if (parser.getDepth() == initialDepth) {
|
||||
break outerloop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,14 +71,13 @@ public class OfferConfirmation extends SimpleIQ {
|
|||
boolean done = false;
|
||||
while (!done) {
|
||||
parser.next();
|
||||
String elementName = parser.getName();
|
||||
if (parser.getEventType() == XmlPullParser.Event.START_ELEMENT && "user-jid".equals(elementName)) {
|
||||
if (parser.getEventType() == XmlPullParser.Event.START_ELEMENT && "user-jid".equals(parser.getName())) {
|
||||
confirmation.setUserJID(parser.nextText());
|
||||
}
|
||||
else if (parser.getEventType() == XmlPullParser.Event.START_ELEMENT && "session-id".equals(elementName)) {
|
||||
else if (parser.getEventType() == XmlPullParser.Event.START_ELEMENT && "session-id".equals(parser.getName())) {
|
||||
confirmation.setSessionID(Long.valueOf(parser.nextText()));
|
||||
}
|
||||
else if (parser.getEventType() == XmlPullParser.Event.END_ELEMENT && "offer-confirmation".equals(elementName)) {
|
||||
else if (parser.getEventType() == XmlPullParser.Event.END_ELEMENT && "offer-confirmation".equals(parser.getName())) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,14 +108,13 @@ public class QueueUpdate implements ExtensionElement {
|
|||
int timeRemaining = -1;
|
||||
while (!done) {
|
||||
parser.next();
|
||||
String elementName = parser.getName();
|
||||
if (parser.getEventType() == XmlPullParser.Event.START_ELEMENT && "position".equals(elementName)) {
|
||||
if (parser.getEventType() == XmlPullParser.Event.START_ELEMENT && "position".equals(parser.getName())) {
|
||||
position = Integer.parseInt(parser.nextText());
|
||||
}
|
||||
else if (parser.getEventType() == XmlPullParser.Event.START_ELEMENT && "time".equals(elementName)) {
|
||||
else if (parser.getEventType() == XmlPullParser.Event.START_ELEMENT && "time".equals(parser.getName())) {
|
||||
timeRemaining = Integer.parseInt(parser.nextText());
|
||||
}
|
||||
else if (parser.getEventType() == XmlPullParser.Event.END_ELEMENT && "queue-status".equals(elementName)) {
|
||||
else if (parser.getEventType() == XmlPullParser.Event.END_ELEMENT && "queue-status".equals(parser.getName())) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,11 +179,10 @@ public class RoomInvitation implements ExtensionElement {
|
|||
final RoomInvitation invitation = new RoomInvitation();
|
||||
invitation.type = Type.valueOf(parser.getAttributeValue("", "type"));
|
||||
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
outerloop: while (true) {
|
||||
parser.next();
|
||||
String elementName = parser.getName();
|
||||
if (parser.getEventType() == XmlPullParser.Event.START_ELEMENT) {
|
||||
String elementName = parser.getName();
|
||||
if ("session".equals(elementName)) {
|
||||
invitation.sessionID = parser.getAttributeValue("", "id");
|
||||
}
|
||||
|
@ -203,8 +202,8 @@ public class RoomInvitation implements ExtensionElement {
|
|||
invitation.room = JidCreate.entityBareFrom(roomString);
|
||||
}
|
||||
}
|
||||
else if (parser.getEventType() == XmlPullParser.Event.END_ELEMENT && ELEMENT_NAME.equals(elementName)) {
|
||||
done = true;
|
||||
else if (parser.getEventType() == XmlPullParser.Event.END_ELEMENT && parser.getDepth() == initialDepth) {
|
||||
break outerloop;
|
||||
}
|
||||
}
|
||||
return invitation;
|
||||
|
|
|
@ -174,11 +174,10 @@ public class RoomTransfer implements ExtensionElement {
|
|||
final RoomTransfer invitation = new RoomTransfer();
|
||||
invitation.type = RoomTransfer.Type.valueOf(parser.getAttributeValue("", "type"));
|
||||
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
outerloop: while (true) {
|
||||
parser.next();
|
||||
String elementName = parser.getName();
|
||||
if (parser.getEventType() == XmlPullParser.Event.START_ELEMENT) {
|
||||
String elementName = parser.getName();
|
||||
if ("session".equals(elementName)) {
|
||||
invitation.sessionID = parser.getAttributeValue("", "id");
|
||||
}
|
||||
|
@ -195,8 +194,8 @@ public class RoomTransfer implements ExtensionElement {
|
|||
invitation.room = parser.nextText();
|
||||
}
|
||||
}
|
||||
else if (parser.getEventType() == XmlPullParser.Event.END_ELEMENT && ELEMENT_NAME.equals(elementName)) {
|
||||
done = true;
|
||||
else if (parser.getEventType() == XmlPullParser.Event.END_ELEMENT && parser.getDepth() == initialDepth) {
|
||||
break outerloop;
|
||||
}
|
||||
}
|
||||
return invitation;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.omemo.provider;
|
||||
|
||||
import static org.jivesoftware.smackx.omemo.element.OmemoBundleElement.BUNDLE;
|
||||
import static org.jivesoftware.smackx.omemo.element.OmemoBundleElement.IDENTITY_KEY;
|
||||
import static org.jivesoftware.smackx.omemo.element.OmemoBundleElement.PRE_KEYS;
|
||||
import static org.jivesoftware.smackx.omemo.element.OmemoBundleElement.PRE_KEY_ID;
|
||||
|
@ -43,7 +42,6 @@ import org.jivesoftware.smackx.omemo.element.OmemoBundleElement_VAxolotl;
|
|||
public class OmemoBundleVAxolotlProvider extends ExtensionElementProvider<OmemoBundleElement_VAxolotl> {
|
||||
@Override
|
||||
public OmemoBundleElement_VAxolotl parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
|
||||
boolean stop = false;
|
||||
boolean inPreKeys = false;
|
||||
|
||||
int signedPreKeyId = -1;
|
||||
|
@ -52,11 +50,11 @@ public class OmemoBundleVAxolotlProvider extends ExtensionElementProvider<OmemoB
|
|||
String identityKey = null;
|
||||
HashMap<Integer, String> preKeys = new HashMap<>();
|
||||
|
||||
while (!stop) {
|
||||
outerloop: while (true) {
|
||||
XmlPullParser.Event tag = parser.next();
|
||||
String name = parser.getName();
|
||||
switch (tag) {
|
||||
case START_ELEMENT:
|
||||
String name = parser.getName();
|
||||
final int attributeCount = parser.getAttributeCount();
|
||||
// <signedPreKeyPublic>
|
||||
if (name.equals(SIGNED_PRE_KEY_PUB)) {
|
||||
|
@ -91,8 +89,8 @@ public class OmemoBundleVAxolotlProvider extends ExtensionElementProvider<OmemoB
|
|||
}
|
||||
break;
|
||||
case END_ELEMENT:
|
||||
if (name.equals(BUNDLE)) {
|
||||
stop = true;
|
||||
if (parser.getDepth() == initialDepth) {
|
||||
break outerloop;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017 Paul Schaub
|
||||
* Copyright 2017 Paul Schaub, 2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -18,7 +18,6 @@ package org.jivesoftware.smackx.omemo.provider;
|
|||
|
||||
import static org.jivesoftware.smackx.omemo.element.OmemoDeviceListElement.DEVICE;
|
||||
import static org.jivesoftware.smackx.omemo.element.OmemoDeviceListElement.ID;
|
||||
import static org.jivesoftware.smackx.omemo.element.OmemoDeviceListElement.LIST;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
|
@ -41,12 +40,11 @@ public class OmemoDeviceListVAxolotlProvider extends ExtensionElementProvider<Om
|
|||
@Override
|
||||
public OmemoDeviceListElement_VAxolotl parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
|
||||
Set<Integer> deviceListIds = new HashSet<>();
|
||||
boolean stop = false;
|
||||
while (!stop) {
|
||||
outerloop: while (true) {
|
||||
XmlPullParser.Event tag = parser.next();
|
||||
String name = parser.getName();
|
||||
switch (tag) {
|
||||
case START_ELEMENT:
|
||||
String name = parser.getName();
|
||||
if (name.equals(DEVICE)) {
|
||||
for (int i = 0; i < parser.getAttributeCount(); i++) {
|
||||
if (parser.getAttributeName(i).equals(ID)) {
|
||||
|
@ -57,8 +55,8 @@ public class OmemoDeviceListVAxolotlProvider extends ExtensionElementProvider<Om
|
|||
}
|
||||
break;
|
||||
case END_ELEMENT:
|
||||
if (name.equals(LIST)) {
|
||||
stop = true;
|
||||
if (parser.getDepth() == initialDepth) {
|
||||
break outerloop;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.jivesoftware.smackx.omemo.provider;
|
||||
|
||||
import static org.jivesoftware.smackx.omemo.element.OmemoElement.ATTR_PAYLOAD;
|
||||
import static org.jivesoftware.smackx.omemo.element.OmemoElement.NAME_ENCRYPTED;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -42,17 +41,16 @@ public class OmemoVAxolotlProvider extends ExtensionElementProvider<OmemoElement
|
|||
|
||||
@Override
|
||||
public OmemoElement_VAxolotl parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
|
||||
boolean inEncrypted = true;
|
||||
int sid = -1;
|
||||
ArrayList<OmemoKeyElement> keys = new ArrayList<>();
|
||||
byte[] iv = null;
|
||||
byte[] payload = null;
|
||||
|
||||
while (inEncrypted) {
|
||||
outerloop: while (true) {
|
||||
XmlPullParser.Event tag = parser.next();
|
||||
String name = parser.getName();
|
||||
switch (tag) {
|
||||
case START_ELEMENT:
|
||||
String name = parser.getName();
|
||||
switch (name) {
|
||||
case OmemoHeaderElement.ELEMENT:
|
||||
for (int i = 0; i < parser.getAttributeCount(); i++) {
|
||||
|
@ -82,8 +80,8 @@ public class OmemoVAxolotlProvider extends ExtensionElementProvider<OmemoElement
|
|||
}
|
||||
break;
|
||||
case END_ELEMENT:
|
||||
if (name.equals(NAME_ENCRYPTED)) {
|
||||
inEncrypted = false;
|
||||
if (parser.getDepth() == initialDepth) {
|
||||
break outerloop;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -42,8 +42,8 @@ public class PubkeyElementProvider extends ExtensionElementProvider<PubkeyElemen
|
|||
Date date = ParserUtils.getDateFromOptionalXep82String(dateString);
|
||||
while (true) {
|
||||
XmlPullParser.Event tag = parser.next();
|
||||
String name = parser.getName();
|
||||
if (tag == XmlPullParser.Event.START_ELEMENT) {
|
||||
String name = parser.getName();
|
||||
switch (name) {
|
||||
case PubkeyElement.PubkeyDataElement.ELEMENT:
|
||||
String base64EncodedOpenPgpPubKey = parser.nextText();
|
||||
|
|
Loading…
Reference in a new issue