summaryrefslogtreecommitdiffstats
path: root/lasso/xml
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2011-11-22 00:18:33 +0100
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2011-11-22 00:18:33 +0100
commit9d13fb1933d401dd0e0855b1625f806f254b49d0 (patch)
tree35cc3e969949bcce73d49900b2c585090acb6d7a /lasso/xml
parent699f0e42d57d252c02002d09cc4f1671f808d95c (diff)
downloadlasso-9d13fb1933d401dd0e0855b1625f806f254b49d0.tar.gz
lasso-9d13fb1933d401dd0e0855b1625f806f254b49d0.tar.xz
lasso-9d13fb1933d401dd0e0855b1625f806f254b49d0.zip
[core] fix wrong XML canonicalization when assertion is extracted without its namespace context
Diffstat (limited to 'lasso/xml')
-rw-r--r--lasso/xml/xml.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c
index f4895316..da5dda42 100644
--- a/lasso/xml/xml.c
+++ b/lasso/xml/xml.c
@@ -846,8 +846,34 @@ lasso_node_set_original_xmlnode(LassoNode *node, xmlNode* xmlnode)
{
if (xmlnode) {
xmlNode *copy = NULL;
+ xmlNode *parent = xmlnode->parent;
copy = xmlCopyNode(xmlnode, 1);
+ /* excl-c14n can move some namespace declarations at the point where the document is
+ * cut, to simulate it we copy on the new node all namespaces from the parents of
+ * the node which are not shadowed by another declaration on this node or one of its
+ * parent. */
+ while (parent && parent->type == XML_ELEMENT_NODE) {
+ xmlNs *ns_def = parent->nsDef;
+ xmlNs *local_ns_def;
+ while (ns_def) {
+ int ok = 1;
+ local_ns_def = copy->nsDef;
+ while (local_ns_def) {
+ if (lasso_strisequal((char*)local_ns_def->prefix, (char*)ns_def->prefix)) {
+ ok = 0;
+ break;
+ }
+ local_ns_def = local_ns_def->next;
+ }
+ if (ok) {
+ xmlNewNs(copy, ns_def->href, ns_def->prefix);
+ }
+ ns_def = ns_def->next;
+ }
+ parent = parent->parent;
+ }
+
if (lasso_flag_memory_debug) {
fprintf(stderr, "setting original xmlnode (at %p) on node %s:%p\n", copy, G_OBJECT_TYPE_NAME (node), node);
}