From 995a384234fd0ba9233ebcce380628bbe346b911 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Mon, 14 Feb 2011 13:04:50 -0800 Subject: 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 --- xml/src/main/java/org/kxml2/io/KXmlParser.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'xml/src/main/java/org/kxml2') 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()))) { -- cgit v1.1