diff options
author | Narayan Kamath <narayan@google.com> | 2013-10-16 14:53:39 +0100 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2013-10-16 14:54:55 +0100 |
commit | 0424d12f9b8a19c4a451282bc8ae974f6109424d (patch) | |
tree | 3111378fa77395bcf3833ce7c8e0593704a7dc36 /xml/src/main/java/org | |
parent | f81c365ac1664a2339cbad371d25f0620aa8ebc7 (diff) | |
download | libcore-0424d12f9b8a19c4a451282bc8ae974f6109424d.zip libcore-0424d12f9b8a19c4a451282bc8ae974f6109424d.tar.gz libcore-0424d12f9b8a19c4a451282bc8ae974f6109424d.tar.bz2 |
Get stricter about DOCTYPEs.
Allow them only before we've started parsing any
XML elements.
bug: 3452274
Change-Id: I7b146e4dae8c7aa23a0a227538ec02604f828400
Diffstat (limited to 'xml/src/main/java/org')
-rw-r--r-- | xml/src/main/java/org/kxml2/io/KXmlParser.java | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/xml/src/main/java/org/kxml2/io/KXmlParser.java b/xml/src/main/java/org/kxml2/io/KXmlParser.java index 84376ae..a90db3b 100644 --- a/xml/src/main/java/org/kxml2/io/KXmlParser.java +++ b/xml/src/main/java/org/kxml2/io/KXmlParser.java @@ -163,6 +163,9 @@ public class KXmlParser implements XmlPullParser, Closeable { private boolean degenerated; private int attributeCount; + // true iff. we've encountered the START_TAG of an XML element at depth == 0; + private boolean parsedTopLevelStartTag; + /* * The current element's attributes arranged in groups of 4: * i + 0 = attribute namespace URI @@ -416,6 +419,9 @@ public class KXmlParser implements XmlPullParser, Closeable { break; case DOCDECL: readDoctype(justOneToken); + if (parsedTopLevelStartTag) { + throw new XmlPullParserException("Unexpected token", this, null); + } break; default: @@ -1128,6 +1134,9 @@ public class KXmlParser implements XmlPullParser, Closeable { } int sp = depth++ * 4; + if (depth == 1) { + parsedTopLevelStartTag = true; + } elementStack = ensureCapacity(elementStack, sp + 4); elementStack[sp + 3] = name; |