[xmlsec] Namespace prefixes on Signature

Aleksey Sanin aleksey at aleksey.com
Mon Jul 17 14:57:16 PDT 2006


The GNOME CVS -> Subversion conversion did not happen and I happily
checked in your patch with one small tweak in xmtree.c to handle the
situation when namespace node found by xmlSearchNsByHref() lookup
has a prefix re-defined later:

<A xmlns:a="http://www.example.org/a">
    <B xmlns:a="http://www.example.org/b">
	<C>
	</C>
    </B>
</A>

If we do a lookup for namespace "http://www.example.org/a" from node
<C> then we would find definition for xmlns:a="http://www.example.org/a"
in node <A>. However, we can not use prefix "a" in the node <C> because
it was already re-defined in node <B>.

The code in the patch did the following:

	nsPtr = xmlSearchNsByHref(cur->doc, cur, ns);
  	if((nsPtr == NULL) || !xmlStrEqual(nsPtr->href, ns)) {
  	    nsPtr = xmlNewNs(cur, ns, NULL);
  	}

and I changed it to do this:

	nsPtr = xmlSearchNsByHref(cur->doc, cur, ns);
	if((nsPtr == NULL) ||
            (xmlSearchNs(cur->doc, cur, nsPtr->prefix) != nsPtr)) {

  	    nsPtr = xmlNewNs(cur, ns, NULL);
  	}


Thanks again for the patch!
Aleksey





More information about the xmlsec mailing list