From 244cbf194044d5932e890e6e223b85b15a7b6807 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sun, 29 Aug 2021 15:53:01 -0400 Subject: [PATCH] Ensure compatibility with Nokogiri Nokogiri v1.12 introduced a breaking change related to namespace inheritance of reparented child nodes. This commit using the feature added in v1.12.4 to opt - for new versions of Nokogiri that support it, set `Document#namespace_inheritance` - intermediate versions of Nokogiri will be avoided via gemspec version specification - old versions of Nokogiri will continue to work See https://github.com/sparklemotion/nokogiri/issues/2320 for more details. Fixes #30 --- lib/signer.rb | 1 + signer.gemspec | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/signer.rb b/lib/signer.rb index 16b9d25..4941355 100644 --- a/lib/signer.rb +++ b/lib/signer.rb @@ -65,6 +65,7 @@ def initialize(document, noblanks: true, wss: true, canonicalize_algorithm: :c14 self.document = Nokogiri::XML(document.to_s) do |config| config.noblanks if noblanks end + self.document.namespace_inheritance = true if self.document.respond_to?(:namespace_inheritance) self.digest_algorithm = :sha1 self.wss = wss self.canonicalize_algorithm = canonicalize_algorithm diff --git a/signer.gemspec b/signer.gemspec index ad5ca9f..405d6af 100644 --- a/signer.gemspec +++ b/signer.gemspec @@ -21,5 +21,5 @@ Gem::Specification.new do |gem| gem.add_development_dependency 'rake' gem.add_development_dependency 'rspec' - gem.add_runtime_dependency 'nokogiri', '>= 1.5.1' + gem.add_runtime_dependency 'nokogiri', '>= 1.5.1', '!=1.12.3', '!=1.12.2', '!=1.12.1', '!=1.12.0' end