summaryrefslogtreecommitdiffstats
path: root/xml
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2011-02-14 13:04:50 -0800
committerJesse Wilson <jessewilson@google.com>2011-02-14 13:23:45 -0800
commit995a384234fd0ba9233ebcce380628bbe346b911 (patch)
treec9ddb1ce4ca0166c95a8684a57d154cae7cf9498 /xml
parent514d10c4faeb28b617b0880fa2326d95ca9a68ca (diff)
downloadlibcore-995a384234fd0ba9233ebcce380628bbe346b911.zip
libcore-995a384234fd0ba9233ebcce380628bbe346b911.tar.gz
libcore-995a384234fd0ba9233ebcce380628bbe346b911.tar.bz2
Fail parsing if there's text outside the document element.
We have a similar bug for misplaced DTDs. This is tested but not fixed by this change. Change-Id: I8e06ec9197cb8c4135212056ab791c254c9dcc3d http://b/3452274
Diffstat (limited to 'xml')
-rw-r--r--xml/src/main/java/org/kxml2/io/KXmlParser.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/xml/src/main/java/org/kxml2/io/KXmlParser.java b/xml/src/main/java/org/kxml2/io/KXmlParser.java
index f9d6461..4b4f328 100644
--- a/xml/src/main/java/org/kxml2/io/KXmlParser.java
+++ b/xml/src/main/java/org/kxml2/io/KXmlParser.java
@@ -422,6 +422,10 @@ public class KXmlParser implements XmlPullParser, Closeable {
throw new XmlPullParserException("Unexpected token", this, null);
}
+ if (depth == 0 && (type == ENTITY_REF || type == TEXT || type == CDSECT)) {
+ throw new XmlPullParserException("Unexpected token", this, null);
+ }
+
if (justOneToken) {
return type;
}
@@ -2027,7 +2031,6 @@ public class KXmlParser implements XmlPullParser, Closeable {
public void require(int type, String namespace, String name)
throws XmlPullParserException, IOException {
-
if (type != this.type
|| (namespace != null && !namespace.equals(getNamespace()))
|| (name != null && !name.equals(getName()))) {