Skip to content

Commit e3dc5bd

Browse files
committed
Restore logic for Utils#element_text
In this commit I'm putting the tests back the way they were and restoring the logic in the Utils.element_text. Instead I'm applying the change that @brianswko suggested at the start of #443 This still allows for my new test to pass.
1 parent 9400c45 commit e3dc5bd

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/onelogin/ruby-saml/response.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def destination
322322
def audiences
323323
@audiences ||= begin
324324
nodes = xpath_from_signed_assertion('/a:Conditions/a:AudienceRestriction/a:Audience')
325-
nodes.map { |node| Utils.element_text(node) }.compact
325+
nodes.map { |node| Utils.element_text(node) }.reject(&:empty?)
326326
end
327327
end
328328

lib/onelogin/ruby-saml/utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def self.original_uri_match?(destination_url, settings_url)
286286
# that there all children other than text nodes can be ignored (e.g. comments). If nil is
287287
# passed, nil will be returned.
288288
def self.element_text(element)
289-
element.texts.join if element && !element.texts.empty?
289+
element.texts.join if element
290290
end
291291
end
292292
end

test/response_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,12 +1137,12 @@ class RubySamlTest < Minitest::Test
11371137

11381138
it "return multiple values including nil and empty string" do
11391139
response = OneLogin::RubySaml::Response.new(fixture(:response_with_multiple_attribute_values))
1140-
assert_equal [nil, "valuePresent", nil, nil], response.attributes.multi(:attribute_with_nils_and_empty_strings)
1140+
assert_equal ["", "valuePresent", nil, nil], response.attributes.multi(:attribute_with_nils_and_empty_strings)
11411141
end
11421142

11431143
it "return multiple values from [] when not in compatibility mode off" do
11441144
OneLogin::RubySaml::Attributes.single_value_compatibility = false
1145-
assert_equal [nil, "valuePresent", nil, nil], response_multiple_attr_values.attributes[:attribute_with_nils_and_empty_strings]
1145+
assert_equal ["", "valuePresent", nil, nil], response_multiple_attr_values.attributes[:attribute_with_nils_and_empty_strings]
11461146
OneLogin::RubySaml::Attributes.single_value_compatibility = true
11471147
end
11481148

0 commit comments

Comments
 (0)