[PATCH 1/3] Fix reading of CDATA elements

Miika Turkia miika.turkia at gmail.com
Tue Oct 28 02:13:59 PDT 2014


If the element we are parsing is of type XML_CDATA_SECTION_NODE, we have
to check the node's name from the parent.

Fixes #718

Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 parse-xml.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/parse-xml.c b/parse-xml.c
index 63ce64f..fb55337 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1526,10 +1526,11 @@ static const char *nodename(xmlNode *node, char *buf, int len)
 	int levels = 2;
 	char *p = buf;
 
-	if (!node || !node->name)
+	if (node->type != XML_CDATA_SECTION_NODE && (!node || !node->name)) {
 		return "root";
+	}
 
-	if (node->parent && !strcmp(node->name, "text"))
+	if (node->type == XML_CDATA_SECTION_NODE || (node->parent && !strcmp(node->name, "text")))
 		node = node->parent;
 
 	/* Make sure it's always NUL-terminated */
-- 
1.9.1



More information about the subsurface mailing list