Fixed an error when transform node is missing. - #51
Open
ketoketo wants to merge 1 commit into
Open
Conversation
|
This solution closes #55 |
|
Hey @benoist, can you check this out? This solves an error which I have been stuck for a few weeks, would be nice to have this merged |
|
@Guistoff081 in the meantime you can monkey patch this module. If you're on a rails app, you can create a file under require 'xmldsig/transforms/enveloped_signature'
module Xmldsig
class Transforms < Array
class EnvelopedSignature < Transform
def transform
signatures = node.xpath("descendant::ds:Signature", Xmldsig::NAMESPACES).
sort { |left, right| left.ancestors.size <=> right.ancestors.size }
signatures.first&.remove
node
end
end
end
end |
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.
Fixed the problem so that no error occurs even if the transform node is missing.
When the XML style is fixed, it is not possible to remove unnecessary transform tags, so we had to deal with it programmatically.
I have prepared a sample xml for testing, so please check it out!
https://github.com/benoist/xmldsig/pull/51/files#diff-3cda4c5dd249c588ecc1d75d1a3936ba3b376294492fe083b33a6c883d4f410dR26-R32