Skip to content

Commit 1f85971

Browse files
committed
Restrict AVD and VD parsing to the current element instead of the whole document
This CL changes the AVD xml parsing to parsing only within the current element, which prevents AVD parsing from always skipping to the end of the doucment. So things that are defined after AVD in the same document can be picked up by the xml parser. The same fix has been applied to VD as well. BUG: 31865175 Test: Manually following comment zsol#1 in the bug above Change-Id: I4ebdce1eb2e92d6f6e2c37caed9607253d24602f
1 parent 20cf001 commit 1f85971

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,11 @@ public void inflate(Resources res, XmlPullParser parser, AttributeSet attrs, The
455455

456456
int eventType = parser.getEventType();
457457
float pathErrorScale = 1;
458-
while (eventType != XmlPullParser.END_DOCUMENT) {
458+
final int innerDepth = parser.getDepth() + 1;
459+
460+
// Parse everything until the end of the animated-vector element.
461+
while (eventType != XmlPullParser.END_DOCUMENT
462+
&& (parser.getDepth() >= innerDepth || eventType != XmlPullParser.END_TAG)) {
459463
if (eventType == XmlPullParser.START_TAG) {
460464
final String tagName = parser.getName();
461465
if (ANIMATED_VECTOR.equals(tagName)) {

graphics/java/android/graphics/drawable/VectorDrawable.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,11 @@ private void inflateChildElements(Resources res, XmlPullParser parser, Attribute
710710
groupStack.push(state.mRootGroup);
711711

712712
int eventType = parser.getEventType();
713-
while (eventType != XmlPullParser.END_DOCUMENT) {
713+
final int innerDepth = parser.getDepth() + 1;
714+
715+
// Parse everything until the end of the vector element.
716+
while (eventType != XmlPullParser.END_DOCUMENT
717+
&& (parser.getDepth() >= innerDepth || eventType != XmlPullParser.END_TAG)) {
714718
if (eventType == XmlPullParser.START_TAG) {
715719
final String tagName = parser.getName();
716720
final VGroup currentGroup = groupStack.peek();

0 commit comments

Comments
 (0)