2010-07-09 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 9 Jul 2010 16:24:09 +0000 (16:24 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 9 Jul 2010 16:24:09 +0000 (16:24 -0000)
* SignedXml.cs : avoid using LoadXml() to load xml element as in
  literal string. Use ImportNode() instead.
  Copy namespaces for a referenced node found in envelope document too.

svn path=/trunk/mcs/; revision=160143

mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog
mcs/class/System.Security/System.Security.Cryptography.Xml/SignedXml.cs

index da40b59bdc04ebb2afb02ef14f93afdc8bb85ea6..8eb7ab31416f60b414ecabfdf25ce3ed33c406e8 100644 (file)
@@ -1,3 +1,9 @@
+2010-07-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SignedXml.cs : avoid using LoadXml() to load xml element as in
+         literal string. Use ImportNode() instead.
+         Copy namespaces for a referenced node found in envelope document too.
+
 2009-07-14  Sebastien Pouliot  <sebastien@ximian.com>
 
        * SignedXml.cs: Fix HMACOutputLength to match XMLDSIG erratum (ref: 
index 4a3a3e0e911cbd519377c8693f5c90a01b3c7ef7..c0aaaa2e76fe75c49948412a04157ebe091fe8f6 100644 (file)
@@ -236,7 +236,7 @@ namespace System.Security.Cryptography.Xml {
                                        XmlElement xel = GetIdElement (signatureElement.OwnerDocument, r.Uri.Substring (1));
                                        if (xel == null)
                                                throw new CryptographicException ("Manifest targeted by Reference was not found: " + r.Uri.Substring (1));
-                                       doc.LoadXml (xel.OuterXml);
+                                       doc.AppendChild (doc.ImportNode (xel, true));
                                        FixupNamespaceNodes (xel, doc.DocumentElement, false);
                                }
                        }
@@ -318,7 +318,7 @@ namespace System.Security.Cryptography.Xml {
                                                if (obj.Id == objectName) {
                                                        found = obj.GetXml ();
                                                        found.SetAttribute ("xmlns", SignedXml.XmlDsigNamespaceUrl);
-                                                       doc.LoadXml (found.OuterXml);
+                                                       doc.AppendChild (doc.ImportNode (found, true));
                                                        // FIXME: there should be theoretical justification of copying namespace declaration nodes this way.
                                                        foreach (XmlNode n in found.ChildNodes)
                                                                // Do not copy default namespace as it must be xmldsig namespace for "Object" element.
@@ -329,8 +329,10 @@ namespace System.Security.Cryptography.Xml {
                                        }
                                        if (found == null && envdoc != null) {
                                                found = GetIdElement (envdoc, objectName);
-                                               if (found != null)
-                                                       doc.LoadXml (found.OuterXml);
+                                               if (found != null) {
+                                                       doc.AppendChild (doc.ImportNode (found, true));
+                                                       FixupNamespaceNodes (found, doc.DocumentElement, false);
+                                               }
                                        }
                                        if (found == null)
                                                throw new CryptographicException (String.Format ("Malformed reference object: {0}", objectName));