xmlsec r1000 - in trunk: . include/xmlsec src src/mscrypto src/nss src/openssl win32



Author: aleksey
Date: Wed Jun  4 15:45:05 2008
New Revision: 1000
URL: http://svn.gnome.org/viewvc/xmlsec?rev=1000&view=rev

Log:
added new function xmlSecNodeEncodeAndSetContent for encoding special chars in the node content

Modified:
   trunk/ChangeLog
   trunk/include/xmlsec/xmltree.h
   trunk/src/keyinfo.c
   trunk/src/mscrypto/x509.c
   trunk/src/nss/x509.c
   trunk/src/openssl/x509.c
   trunk/src/templates.c
   trunk/src/xmltree.c
   trunk/win32/mycfg.bat

Modified: trunk/include/xmlsec/xmltree.h
==============================================================================
--- trunk/include/xmlsec/xmltree.h	(original)
+++ trunk/include/xmlsec/xmltree.h	Wed Jun  4 15:45:05 2008
@@ -74,7 +74,9 @@
 							 const xmlSecByte *buffer, 
 							 xmlSecSize size,
 							 xmlNodePtr* replaced);
-
+XMLSEC_EXPORT int		xmlSecNodeEncodeAndSetContent
+							(xmlNodePtr node,
+							 const xmlChar *buffer);
 XMLSEC_EXPORT void		xmlSecAddIDs		(xmlDocPtr doc,
 							 xmlNodePtr cur,
 							 const xmlChar** ids);

Modified: trunk/src/keyinfo.c
==============================================================================
--- trunk/src/keyinfo.c	(original)
+++ trunk/src/keyinfo.c	Wed Jun  4 15:45:05 2008
@@ -779,8 +779,7 @@
 
     name = xmlSecKeyGetName(key);
     if(name != NULL) {
-	/* TODO: encode the key name */
-	xmlNodeSetContent(node, name);
+	    xmlSecNodeEncodeAndSetContent(node, name);
     }
     return(0);
 }

Modified: trunk/src/mscrypto/x509.c
==============================================================================
--- trunk/src/mscrypto/x509.c	(original)
+++ trunk/src/mscrypto/x509.c	Wed Jun  4 15:45:05 2008
@@ -1165,7 +1165,7 @@
 	xmlFree(buf);
 	return(-1);
     }
-    xmlNodeSetContent(cur, buf);
+    xmlSecNodeEncodeAndSetContent(cur, buf);
     xmlFree(buf);
     return(0);
 }
@@ -1358,7 +1358,7 @@
 		    XMLSEC_ERRORS_NO_MESSAGE);
 	return(-1);
     }
-    xmlNodeSetContent(issuerNameNode, buf);
+    xmlSecNodeEncodeAndSetContent(issuerNameNode, buf);
     xmlFree(buf);
 
     ret = xmlSecMSCryptoASN1IntegerWrite(issuerNumberNode, &(cert->pCertInfo->SerialNumber));
@@ -1473,7 +1473,7 @@
 	xmlFree(buf);
 	return(-1);
     }
-    xmlNodeSetContent(cur, buf);
+    xmlSecNodeEncodeAndSetContent(cur, buf);
     xmlFree(buf);
 
     return(0);

Modified: trunk/src/nss/x509.c
==============================================================================
--- trunk/src/nss/x509.c	(original)
+++ trunk/src/nss/x509.c	Wed Jun  4 15:45:05 2008
@@ -1196,7 +1196,7 @@
 	xmlFree(buf);
 	return(-1);
     }
-    xmlNodeSetContent(cur, buf);
+    xmlSecNodeEncodeAndSetContent(cur, buf);
     xmlFree(buf);
     return(0);
 }
@@ -1386,7 +1386,7 @@
 		    XMLSEC_ERRORS_NO_MESSAGE);
 	return(-1);
     }
-    xmlNodeSetContent(issuerNameNode, buf);
+    xmlSecNodeEncodeAndSetContent(issuerNameNode, buf);
     xmlFree(buf);
 
     buf = xmlSecNssASN1IntegerWrite(&(cert->serialNumber));
@@ -1504,7 +1504,7 @@
 	xmlFree(buf);
 	return(-1);
     }
-    xmlNodeSetContent(cur, buf);
+    xmlSecNodeEncodeAndSetContent(cur, buf);
     xmlFree(buf);
 
     return(0);

Modified: trunk/src/openssl/x509.c
==============================================================================
--- trunk/src/openssl/x509.c	(original)
+++ trunk/src/openssl/x509.c	Wed Jun  4 15:45:05 2008
@@ -1154,7 +1154,7 @@
 	xmlFree(buf);
 	return(-1);
     }
-    xmlNodeSetContent(cur, buf);
+    xmlSecNodeEncodeAndSetContent(cur, buf);
     xmlFree(buf);
     return(0);
 }
@@ -1357,7 +1357,7 @@
 		    XMLSEC_ERRORS_NO_MESSAGE);
 	return(-1);
     }
-    xmlNodeSetContent(issuerNameNode, buf);
+    xmlSecNodeEncodeAndSetContent(issuerNameNode, buf);
     xmlFree(buf);
 
     buf = xmlSecOpenSSLASN1IntegerWrite(X509_get_serialNumber(cert));
@@ -1369,7 +1369,7 @@
 		    XMLSEC_ERRORS_NO_MESSAGE);
 	return(-1);
     }
-    xmlNodeSetContent(issuerNumberNode, buf);
+    xmlSecNodeEncodeAndSetContent(issuerNumberNode, buf);
     xmlFree(buf);
 
     return(0);
@@ -1488,7 +1488,7 @@
 	xmlFree(buf);
 	return(-1);
     }
-    xmlNodeSetContent(cur, buf);
+    xmlSecNodeEncodeAndSetContent(cur, buf);
     xmlFree(buf);
 
     return(0);

Modified: trunk/src/templates.c
==============================================================================
--- trunk/src/templates.c	(original)
+++ trunk/src/templates.c	Wed Jun  4 15:45:05 2008
@@ -1221,7 +1221,7 @@
 	return(NULL);	
     }
     if(name != NULL) {
-	xmlNodeSetContent(res, name);
+	xmlSecNodeEncodeAndSetContent(res, name);
     }
     return(res);
 }
@@ -1518,7 +1518,7 @@
     }
 
 		if (issuerName != NULL) {
-			xmlNodeSetContent(res, issuerName);
+			xmlSecNodeEncodeAndSetContent(res, issuerName);
 		}
 		return(res);
 }
@@ -1561,7 +1561,7 @@
 	}
 
 	if (serial != NULL) {
-		xmlNodeSetContent(res, serial);
+		xmlSecNodeEncodeAndSetContent(res, serial);
 	}
 	return(res);
 }
@@ -1960,7 +1960,7 @@
 	return(-1);    
     }
     
-    xmlNodeSetContent(xpathNode, expression);
+    xmlSecNodeEncodeAndSetContent(xpathNode, expression);
     return((nsList != NULL) ? xmlSecTmplNodeWriteNsList(xpathNode, nsList) : 0);
 }
 
@@ -1998,7 +1998,7 @@
     }
     xmlSetProp(xpathNode, xmlSecAttrFilter, type);
     
-    xmlNodeSetContent(xpathNode, expression);
+    xmlSecNodeEncodeAndSetContent(xpathNode, expression);
     return((nsList != NULL) ? xmlSecTmplNodeWriteNsList(xpathNode, nsList) : 0);
 }
 
@@ -2044,7 +2044,7 @@
     }
     
     
-    xmlNodeSetContent(xpointerNode, expression);
+    xmlSecNodeEncodeAndSetContent(xpointerNode, expression);
     return((nsList != NULL) ? xmlSecTmplNodeWriteNsList(xpointerNode, nsList) : 0);
 }
 

Modified: trunk/src/xmltree.c
==============================================================================
--- trunk/src/xmltree.c	(original)
+++ trunk/src/xmltree.c	Wed Jun  4 15:45:05 2008
@@ -598,6 +598,43 @@
 }
 
 /**
+ * xmlSecNodeEncodeAndSetContent:
+ * @node: 		    the pointer to an XML node.
+ * @buffer: 		the pointer to the node content.
+ *
+ * Encodes "special" characters in the @buffer and sets the result
+ * as the node content.
+ *
+ * Returns 0 on success or a negative value if an error occurs.
+ */
+int
+xmlSecNodeEncodeAndSetContent(xmlNodePtr node, const xmlChar * buffer) {
+    xmlSecAssert2(node != NULL, -1);
+    xmlSecAssert2(node->doc != NULL, -1);
+    
+    if(buffer != NULL) {
+	    xmlChar * tmp;
+
+        tmp = xmlEncodeSpecialChars(node->doc, buffer);        
+        if (tmp == NULL) {
+            xmlSecError(XMLSEC_ERRORS_HERE,
+                        NULL,
+                        "xmlEncodeSpecialChars",
+                        XMLSEC_ERRORS_R_XML_FAILED,
+                        "Failed to encode special characters");
+            return(-1);         
+        }
+
+        xmlNodeSetContent(node, tmp);
+        xmlFree(tmp);
+    } else {
+        xmlNodeSetContent(node, NULL);
+    }
+
+    return(0);
+}
+
+/**
  * xmlSecAddIDs:
  * @doc: 		the pointer to an XML document.
  * @cur: 		the pointer to an XML node.

Modified: trunk/win32/mycfg.bat
==============================================================================
Binary files. No diff available.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]