[xmlsec] Problem with xmlSecTransformXsltAdd

Aleksey Sanin aleksey at aleksey.com
Mon Feb 24 10:12:23 PST 2003


Greetings! You actually found a bug. The attached patch fixes the problem.
It is checked in the XMLSEC_0_0_X_BRANCH branch as well.

Thanks for bug report,
Aleksey
-------------- next part --------------
Index: src/xmltree.c
===================================================================
RCS file: /cvs/gnome/xmlsec/src/xmltree.c,v
retrieving revision 1.10
diff -u -r1.10 xmltree.c
--- src/xmltree.c	16 Aug 2002 03:46:31 -0000	1.10
+++ src/xmltree.c	24 Feb 2003 18:31:52 -0000
@@ -600,6 +600,7 @@
 	    
     xmlNodeSetContent(node, NULL);
     xmlAddChild(node, ptr);
+    xmlSetTreeDoc(ptr, node->doc);
     return(0);
 }
 
Index: src/xslt.c
===================================================================
RCS file: /cvs/gnome/xmlsec/src/xslt.c,v
retrieving revision 1.7
diff -u -r1.7 xslt.c
--- src/xslt.c	15 Aug 2002 20:27:16 -0000	1.7
+++ src/xslt.c	24 Feb 2003 18:31:52 -0000
@@ -383,10 +383,30 @@
  */
 int
 xmlSecTransformXsltAdd(xmlNodePtr transformNode, const xmlChar *xslt) {
+    xmlDocPtr xslt_doc;
+    int ret;
+        
     xmlSecAssert2(transformNode != NULL, -1);    
     xmlSecAssert2(xslt != NULL, -1);    
     
-    xmlNodeSetContent(transformNode, xslt);
+    xslt_doc = xmlParseMemory(xslt, xmlStrlen(xslt));
+    if(xslt_doc == NULL) {
+	xmlSecError(XMLSEC_ERRORS_HERE,
+		    XMLSEC_ERRORS_R_XML_FAILED,
+		    "xmlParseMemory");
+	return(-1);
+    }
+    
+    ret = xmlSecReplaceContent(transformNode, xmlDocGetRootElement(xslt_doc));
+    if(ret < 0) {
+	xmlSecError(XMLSEC_ERRORS_HERE,
+		    XMLSEC_ERRORS_R_XMLSEC_FAILED,
+		    "xmlSecReplaceContent");
+	xmlFreeDoc(xslt_doc);
+	return(-1);
+    }
+    
+    xmlFreeDoc(xslt_doc);
     return(0);
 }
 


More information about the xmlsec mailing list