Correct behavior for XML canonicalization with namespaces and nested elements#242
Merged
LoneRifle merged 4 commits intonode-saml:masterfrom Jul 8, 2022
Conversation
Contributor
Author
|
In addition to the failing test, I've pushed up what I think may be a fix, in 27ca996. |
Contributor
|
I seems to me that duplicating the namespace doesn't result in non-conforming XML, just hard-to-read XML. If you apply a linter, the XML could clean right up. Having said that, I'm all for cleanly generated XML. For example, you mention that this library results in: <child1 xmlns:aaa="bbb">
<child2>
<child3 xmlns:aaa="bbb" aaa:foo="bar">
</child3>
</child2>
</child1>After running <child1 xmlns:aaa="bbb">
<child2>
<child3 aaa:foo="bar">
</child3>
</child2>
</child1>That says to me that this library could do a better job and generating XML and the PR helps with that. See https://stackoverflow.com/questions/27821554/how-to-eliminate-duplicate-xml-namespace-definitions |
cjbarth
approved these changes
Jul 7, 2022
LoneRifle
approved these changes
Jul 8, 2022
Collaborator
LoneRifle
left a comment
There was a problem hiding this comment.
lgtm, taking reference from @cjbarth and node-saml/node-saml#36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey there! I wanted to start by saying thank you for the hard work maintaining this package.
I've been running into problems related to mismatched signature digests when validating a signed XML document, and I've narrowed the mismatch down to differences in how this library and another canonicalize the document. While the real world example involves SAML response XML, I've tried to instead demonstrate the behavior with a minimal failing test.
For the
http://www.w3.org/TR/2001/REC-xml-c14n-20010315method, I noticed thatxml-cryptoseems to be repeating namespaces that are already defined on an ancestor node.If we start with this document...
...and like in the test, canonicalize the subset of the document with
child1, we get...Notice that
xmlns:aaagets pushed down from theroottochild1, which I expect, but then the namespace is also repeated onchild3.Is this expected behavior? It seems incorrect, due to the duplication of
xmlns:aaa.