From 395b994707e278ea6bc650d0ac88c04a2245df6b Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Sun, 4 Oct 2020 13:36:36 +0000 Subject: [PATCH] Fix: Set namespace correctly for child nodes --- src/reportxml.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/reportxml.c b/src/reportxml.c index 56d49477..51597d58 100644 --- a/src/reportxml.c +++ b/src/reportxml.c @@ -598,7 +598,7 @@ reportxml_node_t * reportxml_node_copy(reportxml_node_t *node) return __reportxml_node_copy_with_db(node, NULL, -1); } -xmlNodePtr reportxml_node_render_xmlnode(reportxml_node_t *node) +static xmlNodePtr reportxml_node_render_xmlnode_with_ns(reportxml_node_t *node, xmlNsPtr ns) { xmlNodePtr ret; ssize_t child_count; @@ -631,13 +631,14 @@ xmlNodePtr reportxml_node_render_xmlnode(reportxml_node_t *node) xmlns = xmlGetProp(ret, XMLSTR("xmlns")); if (xmlns) { - xmlNsPtr ns; xmlUnsetProp(ret, XMLSTR("xmlns")); ns = xmlNewNs(ret, xmlns, NULL); - xmlSetNs(ret, ns); xmlFree(xmlns); } + if (ns) + xmlSetNs(ret, ns); + for (i = 0; i < (size_t)child_count; i++) { reportxml_node_t *child = reportxml_node_get_child(node, i); xmlNodePtr xmlchild; @@ -647,7 +648,7 @@ xmlNodePtr reportxml_node_render_xmlnode(reportxml_node_t *node) return NULL; } - xmlchild = reportxml_node_render_xmlnode(child); + xmlchild = reportxml_node_render_xmlnode_with_ns(child, ns); refobject_unref(child); if (!xmlchild) { xmlFreeNode(ret); @@ -683,6 +684,11 @@ xmlNodePtr reportxml_node_render_xmlnode(reportxml_node_t *node) return ret; } +xmlNodePtr reportxml_node_render_xmlnode(reportxml_node_t *node) +{ + return reportxml_node_render_xmlnode_with_ns(node, NULL); +} + reportxml_node_type_t reportxml_node_get_type(reportxml_node_t *node) { if (!node)