Skip to content

Fixed an error when transform node is missing. - #51

Open
ketoketo wants to merge 1 commit into
benoist:masterfrom
ketoketo:fixed-transform-node-not-exist
Open

Fixed an error when transform node is missing.#51
ketoketo wants to merge 1 commit into
benoist:masterfrom
ketoketo:fixed-transform-node-not-exist

Conversation

@ketoketo

@ketoketo ketoketo commented Nov 26, 2021

Copy link
Copy Markdown

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

@salami96

salami96 commented Feb 4, 2023

Copy link
Copy Markdown

This solution closes #55

@Guistoff081

Copy link
Copy Markdown

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

@alanBAguero

Copy link
Copy Markdown

@Guistoff081 in the meantime you can monkey patch this module. If you're on a rails app, you can create a file under config/initializers:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants