[core] remember if a tag is parsed from CDATA

This commit is contained in:
Seven Du
2019-11-16 10:33:48 +08:00
committed by Andrey Volk
parent 5df8bfcd84
commit 917d850b04
4 changed files with 83 additions and 4 deletions
+2 -1
View File
@@ -69,7 +69,8 @@ SWITCH_BEGIN_EXTERN_C
SWITCH_XML_ROOT = (1 << 0), // root
SWITCH_XML_NAMEM = (1 << 1), // name is malloced
SWITCH_XML_TXTM = (1 << 2), // txt is malloced
SWITCH_XML_DUP = (1 << 3) // attribute name and value are strduped
SWITCH_XML_DUP = (1 << 3), // attribute name and value are strduped
SWITCH_XML_CDATA = (1 << 4) // body is in CDATA
} switch_xml_flag_t;
/*! \brief A representation of an XML tree */
+6 -2
View File
@@ -1139,10 +1139,14 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str(char *s, switch_size_t len)
if (!(s = strstr(s + 3, "--")) || (*(s += 2) != '>' && *s) || (!*s && e != '>'))
return switch_xml_err(root, d, "unclosed <!--");
} else if (!strncmp(s, "![CDATA[", 8)) { /* cdata */
if ((s = strstr(s, "]]>")))
if ((s = strstr(s, "]]>"))) {
if (root && root->cur) {
root->cur->flags |= SWITCH_XML_CDATA;
}
switch_xml_char_content(root, d + 8, (s += 2) - d - 10, 'c');
else
} else {
return switch_xml_err(root, d, "unclosed <![CDATA[");
}
} else if (!strncmp(s, "!DOCTYPE", 8)) { /* dtd */
for (l = 0; *s && ((!l && *s != '>') || (l && (*s != ']' || *(s + strspn(s + 1, SWITCH_XML_WS) + 1) != '>'))); l = (*s == '[') ? 1 : l)
s += strcspn(s + 1, "[]>") + 1;