summaryrefslogtreecommitdiffstats
path: root/xml/src/main/java/org/kxml2
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-11-17 13:47:34 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-11-17 13:47:34 -0800
commit6afd1e297342111db635163614383d62937ce5eb (patch)
tree8cca1c6428a7bc553d86a1f4b801e221f3479cd9 /xml/src/main/java/org/kxml2
parentee5f44de3c4fd9e2bea3aa3801cf93ec4d334446 (diff)
parent6bcf32ab404c39b85d25430f6df16503ef3526cf (diff)
downloadlibcore-6afd1e297342111db635163614383d62937ce5eb.zip
libcore-6afd1e297342111db635163614383d62937ce5eb.tar.gz
libcore-6afd1e297342111db635163614383d62937ce5eb.tar.bz2
Merge change I49b05da2
* changes: Various XML fixes.
Diffstat (limited to 'xml/src/main/java/org/kxml2')
-rw-r--r--xml/src/main/java/org/kxml2/io/KXmlParser.java24
1 files changed, 19 insertions, 5 deletions
diff --git a/xml/src/main/java/org/kxml2/io/KXmlParser.java b/xml/src/main/java/org/kxml2/io/KXmlParser.java
index 98aae04..c4d8f3d 100644
--- a/xml/src/main/java/org/kxml2/io/KXmlParser.java
+++ b/xml/src/main/java/org/kxml2/io/KXmlParser.java
@@ -319,7 +319,9 @@ public class KXmlParser implements XmlPullParser {
return;
case TEXT :
- pushText('<', !token);
+ // BEGIN android-changed: distinguish attribute values from normal text.
+ pushText('<', !token, false);
+ // END android-changed
if (depth == 0) {
if (isWhitespace)
type = IGNORABLE_WHITESPACE;
@@ -680,7 +682,9 @@ public class KXmlParser implements XmlPullParser {
read();
int p = txtPos;
- pushText(delimiter, true);
+ // BEGIN android-changed: distinguish attribute values from normal text.
+ pushText(delimiter, true, true);
+ // END android-changed
attributes[i] = get(p);
txtPos = p;
@@ -800,7 +804,7 @@ public class KXmlParser implements XmlPullParser {
' ': parse to whitespace or '>'
*/
- private final void pushText(int delimiter, boolean resolveEntities)
+ private final void pushText(int delimiter, boolean resolveEntities, boolean inAttributeValue)
throws IOException, XmlPullParserException {
int next = peek(0);
@@ -812,21 +816,31 @@ public class KXmlParser implements XmlPullParser {
if (next <= ' ' || next == '>')
break;
+ // BEGIN android-changed: "<" is not allowed in attribute values.
if (next == '&') {
if (!resolveEntities)
break;
pushEntity();
}
+ else if (next == '<' && inAttributeValue) {
+ error("Illegal: \"<\" inside attribute value");
+ }
else if (next == '\n' && type == START_TAG) {
read();
push(' ');
}
else
push(read());
+ // END android-changed
- if (next == '>' && cbrCount >= 2 && delimiter != ']')
- error("Illegal: ]]>");
+ // BEGIN android-changed: "]]>" *is* allowed in attribute values, but
+ // is not allowed in regular text between markup.
+ final boolean allowCloseCdata = inAttributeValue;
+ if (!allowCloseCdata && (next == '>' && cbrCount >= 2 && delimiter != ']')) {
+ error("Illegal: \"]]>\" outside CDATA section");
+ }
+ // END android-changed
if (next == ']')
cbrCount++;