Check some XML tag names more strictly

This commit is contained in:
Andreas Schildbach 2013-11-08 20:21:32 +01:00
parent c1f6727a4e
commit a5a4e47830
2 changed files with 8 additions and 13 deletions

View file

@ -338,11 +338,11 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
pp.setInput(reader); pp.setInput(reader);
assertResC(pp); assertResC(pp);
XmlPullUtil.enter(pp); XmlPullUtil.enter(pp, "ResC");
XmlPullUtil.require(pp, "LocValRes"); XmlPullUtil.require(pp, "LocValRes");
XmlPullUtil.requireAttr(pp, "id", "req"); XmlPullUtil.requireAttr(pp, "id", "req");
XmlPullUtil.enter(pp); XmlPullUtil.enter(pp, "LocalValRes");
while (pp.getEventType() == XmlPullParser.START_TAG) while (pp.getEventType() == XmlPullParser.START_TAG)
{ {
@ -361,7 +361,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
XmlPullUtil.next(pp); XmlPullUtil.next(pp);
} }
XmlPullUtil.exit(pp); XmlPullUtil.exit(pp, "LocalValRes");
return results; return results;
} }
@ -1426,7 +1426,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
trips.add(new Trip(id, departureLocation, arrivalLocation, legs, null, capacity, numTransfers)); trips.add(new Trip(id, departureLocation, arrivalLocation, legs, null, capacity, numTransfers));
} }
XmlPullUtil.exit(pp); XmlPullUtil.exit(pp, "ConnectionList");
return new QueryTripsResult(header, null, from, via, to, context, trips); return new QueryTripsResult(header, null, from, via, to, context, trips);
} }
@ -1463,13 +1463,13 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
while (XmlPullUtil.test(pp, "AttributeVariant")) while (XmlPullUtil.test(pp, "AttributeVariant"))
{ {
final String type = XmlPullUtil.attr(pp, "type"); final String type = XmlPullUtil.attr(pp, "type");
XmlPullUtil.enter(pp); XmlPullUtil.enter(pp, "AttributeVariant");
final String value; final String value;
if (XmlPullUtil.test(pp, "Text")) if (XmlPullUtil.test(pp, "Text"))
value = XmlPullUtil.text(pp).trim(); value = XmlPullUtil.text(pp).trim();
else else
value = null; value = null;
XmlPullUtil.exit(pp); XmlPullUtil.exit(pp, "AttributeVariant");
attributeVariants.put(type, value); attributeVariants.put(type, value);
} }

View file

@ -20,11 +20,6 @@ public final class XmlPullUtil
pp.require(XmlPullParser.START_TAG, null, tagName); pp.require(XmlPullParser.START_TAG, null, tagName);
} }
/**
* enters current tag
*
* @throws IOException
*/
public static void enter(final XmlPullParser pp) throws XmlPullParserException, IOException public static void enter(final XmlPullParser pp) throws XmlPullParserException, IOException
{ {
if (pp.getEventType() != XmlPullParser.START_TAG) if (pp.getEventType() != XmlPullParser.START_TAG)
@ -82,8 +77,8 @@ public final class XmlPullUtil
if (!pp.isEmptyElementTag()) if (!pp.isEmptyElementTag())
{ {
enter(pp); enter(pp, tagName);
exit(pp); exit(pp, tagName);
} }
else else
{ {