Skip to content

Commit deb7be1

Browse files
committed
Return attributes always in reverse-XML order
1 parent 4b3ff94 commit deb7be1

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

lib/onelogin/ruby-saml/response.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def sessionindex
5050

5151
# A hash of all the attributes with the response.
5252
# Multiple values will be returned in the AttributeValue#values array
53+
# in reverse order, when compared to XML
5354
def attributes
5455
@attr_statements ||= begin
5556
result = {}
@@ -62,7 +63,7 @@ def attributes
6263
values = attr_element.elements.collect(&:text)
6364

6465
# Set up a string-like wrapper for the values array
65-
attr_value = AttributeValue.new(values.first, values)
66+
attr_value = AttributeValue.new(values.first, values.reverse)
6667
# Merge values if the Attribute has already been seen
6768
if result[name]
6869
attr_value.values += result[name].values

test/response_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class RubySamlTest < Test::Unit::TestCase
237237

238238
should "return array with all attributes when asked" do
239239
response = OneLogin::RubySaml::Response.new(fixture(:response_with_multiple_attribute_values))
240-
assert_equal ['value1', 'value2'], response.attributes[:another_value].values
240+
assert_equal ['value2', 'value1'], response.attributes[:another_value].values
241241
end
242242

243243
should "return last of multiple values when multiple Attribute tags in XML" do

0 commit comments

Comments
 (0)