Skip to content

Commit aa489cd

Browse files
committed
Self closing tags returning "" instead of nil
It was discovered that self closing tags return "" now instead of nil. Discussed the possible fixes on: #443
1 parent 082249e commit aa489cd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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
289+
element.texts.join if element && !element.texts.empty?
290290
end
291291
end
292292
end

test/response_test.rb

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

11301130
it "return multiple values including nil and empty string" do
11311131
response = OneLogin::RubySaml::Response.new(fixture(:response_with_multiple_attribute_values))
1132-
assert_equal ["", "valuePresent", nil, nil], response.attributes.multi(:attribute_with_nils_and_empty_strings)
1132+
assert_equal [nil, "valuePresent", nil, nil], response.attributes.multi(:attribute_with_nils_and_empty_strings)
11331133
end
11341134

11351135
it "return multiple values from [] when not in compatibility mode off" do
11361136
OneLogin::RubySaml::Attributes.single_value_compatibility = false
1137-
assert_equal ["", "valuePresent", nil, nil], response_multiple_attr_values.attributes[:attribute_with_nils_and_empty_strings]
1137+
assert_equal [nil, "valuePresent", nil, nil], response_multiple_attr_values.attributes[:attribute_with_nils_and_empty_strings]
11381138
OneLogin::RubySaml::Attributes.single_value_compatibility = true
11391139
end
11401140

0 commit comments

Comments
 (0)