diff options
author | Jesse Wilson <jessewilson@google.com> | 2011-02-14 13:04:50 -0800 |
---|---|---|
committer | Jesse Wilson <jessewilson@google.com> | 2011-02-14 13:23:45 -0800 |
commit | 995a384234fd0ba9233ebcce380628bbe346b911 (patch) | |
tree | c9ddb1ce4ca0166c95a8684a57d154cae7cf9498 /xml | |
parent | 514d10c4faeb28b617b0880fa2326d95ca9a68ca (diff) | |
download | libcore-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.java | 5 |
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()))) { |