Skip to content

Commit 952ce04

Browse files
committed
Change falling back to nil instead of empty list...
Nokogiri for MRI handles [] and nil the same when calling #canonicalize However, Nokogir for JRuby blows up with []. The default argument according to the method definition is nil, so I believe it's more appropriate: http://www.rubydoc.info/github/sparklemotion/nokogiri/Nokogiri/XML/Node#canonicalize-instance_method
1 parent 582ad4c commit 952ce04

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/xml_security.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def extract_inclusive_namespaces
336336
prefix_list = element.attributes.get_attribute("PrefixList").value
337337
prefix_list.split(" ")
338338
else
339-
[]
339+
nil
340340
end
341341
end
342342

test/xml_security_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,14 @@ class XmlSecurityTest < Minitest::Test
168168
assert response.validate!
169169
end
170170

171-
it "return an empty list when inclusive namespace element is missing" do
171+
it "return nil when inclusive namespace element is missing" do
172172
response = fixture(:no_signature_ns, false)
173173
response.slice! %r{<InclusiveNamespaces xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="#default saml ds xs xsi"/>}
174174

175175
document = XMLSecurity::SignedDocument.new(response)
176176
inclusive_namespaces = document.send(:extract_inclusive_namespaces)
177177

178-
assert inclusive_namespaces.empty?
178+
assert inclusive_namespaces.nil?
179179
end
180180
end
181181

0 commit comments

Comments
 (0)