Skip to content

Commit

Permalink
Fix C14N
Browse files Browse the repository at this point in the history
  • Loading branch information
kripper committed Sep 7, 2022
1 parent c3216a4 commit 1e44159
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/Peachpie.Library.XmlDom/DOMNode.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography.Xml;
using System.Text;
using System.Xml;
using Pchp.Core;
Expand Down Expand Up @@ -631,11 +633,19 @@ public PhpString C14N(
PhpArray xpath = null,
PhpArray ns_prefixes = null)
{
var transform = new System.Security.Cryptography.Xml.XmlDsigC14NTransform();
transform.LoadInput(XmlNode.GetXmlDocument());
var stream = (System.IO.MemoryStream)transform.GetOutput(typeof(System.IO.Stream));
XmlNodeReader reader = new XmlNodeReader(XmlNode);
Stream inputStream = new MemoryStream();
XmlWriter writer = new XmlTextWriter(inputStream, Encoding.UTF8);

return new PhpString(stream.ToArray());
writer.WriteNode(reader, false);
writer.Flush();

inputStream.Position = 0;
XmlDsigC14NTransform transform = new XmlDsigC14NTransform();
transform.LoadInput(inputStream);

System.IO.MemoryStream outputStream = (System.IO.MemoryStream)transform.GetOutput(typeof(System.IO.Stream));
return new PhpString(outputStream.ToArray());
}

/// <summary>
Expand Down

0 comments on commit 1e44159

Please sign in to comment.