Skip to content

Commit 57f6af1

Browse files
authored
Merge pull request dotnet/corefx#2 from anthonylangsworth/PropagatedNamespace
Fix Transform.PropagatedNamespace and test Commit migrated from dotnet/corefx@2740de0
2 parents 0975213 + 4f68f01 commit 57f6af1

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Transform.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public Hashtable PropagatedNamespaces
204204
CanonicalXmlNodeList namespaces = null;
205205
if (reference != null)
206206
namespaces = reference._namespaces;
207-
else if (signedXml._context != null)
207+
else if (signedXml?._context != null)
208208
namespaces = Utils.GetPropagatedAttributes(signedXml._context);
209209

210210
// if no namespaces have been propagated, return an empty hashtable.

src/libraries/System.Security.Cryptography.Xml/tests/XmlDsigC14NTransformTest.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void LoadInputAsXmlDocument()
9393
Assert.Equal(c14xml3, output);
9494
}
9595

96-
[Fact()]
96+
[Fact]
9797
// see LoadInputAsXmlNodeList2 description
9898
public void LoadInputAsXmlNodeList()
9999
{
@@ -106,7 +106,7 @@ public void LoadInputAsXmlNodeList()
106106
Assert.Equal(@"<Test xmlns=""http://www.go-mono.com/""></Test>", output);
107107
}
108108

109-
[Fact()]
109+
[Fact]
110110
// MS has a bug that those namespace declaration nodes in
111111
// the node-set are written to output. Related spec section is:
112112
// http://www.w3.org/TR/2001/REC-xml-c14n-20010315#ProcessingModel
@@ -387,7 +387,7 @@ public void PrefixlessNamespaceOutput()
387387
Assert.Equal("urn:foo", doc.DocumentElement.GetAttribute("xmlns"));
388388
}
389389

390-
[Fact(Skip = "TODO: fix me")]
390+
[Fact]
391391
public void PropagatedNamespaces()
392392
{
393393
XmlDocument doc = new XmlDocument();
@@ -397,12 +397,15 @@ public void PropagatedNamespaces()
397397
XmlDsigExcC14NTransform t = new XmlDsigExcC14NTransform();
398398
t.LoadInput(doc);
399399
t.PropagatedNamespaces.Add("f", "urn:foo");
400-
t.PropagatedNamespaces.Add("f", "urn:foo");
401-
t.PropagatedNamespaces.Add("f", "urn:foo");
402400
t.PropagatedNamespaces.Add("b", "urn:bar");
403-
Stream s = t.GetOutput() as Stream;
404-
Assert.Equal(new StreamReader(s, Encoding.UTF8).ReadToEnd(), "<f:foo xmlns:f=\"urn:foo\"><b:bar xmlns:b=\"urn:bar\"></b:bar></f:foo>");
405-
Assert.Equal("urn:foo", doc.DocumentElement.GetAttribute("xmlns:f"));
401+
using (Stream s = t.GetOutput() as Stream)
402+
using (StreamReader streamReader = new StreamReader(s, Encoding.UTF8))
403+
{
404+
string result = streamReader.ReadToEnd();
405+
Assert.Equal(result,
406+
"<foo xmlns=\"urn:foo\"><bar xmlns=\"urn:bar\"></bar></foo>");
407+
Assert.Equal("urn:foo", doc.DocumentElement.NamespaceURI);
408+
}
406409
}
407410

408411
[Fact]

0 commit comments

Comments
 (0)