diff --git a/src/esaml.erl b/src/esaml.erl index 5cc1f7f..46eb78a 100644 --- a/src/esaml.erl +++ b/src/esaml.erl @@ -292,15 +292,11 @@ decode_assertion_attributes(Xml) -> case [X#xmlAttribute.value || X <- AttrElem#xmlElement.attributes, X#xmlAttribute.name =:= 'Name'] of [Name] -> case xmerl_xpath:string("saml:AttributeValue/text()", AttrElem, [{namespace, Ns}]) of - [#xmlText{value = Value}] -> - [{common_attrib_map(Name), Value} | [{Name, Value} | In]]; + [] -> + In; List -> - if (length(List) > 0) -> - Value = [X#xmlText.value || X <- List, element(1, X) =:= xmlText], - [{common_attrib_map(Name), Value} | [{Name, Value} | In]]; - true -> - In - end + Value = [X#xmlText.value || X <- List, element(1, X) =:= xmlText], + [{common_attrib_map(Name), Value} | [{Name, Value} | In]] end; _ -> In end @@ -660,7 +656,7 @@ decode_attributes_test() -> {Doc, _} = xmerl_scan:string("foobartest@test.comgeorgebartest@test.com", [{namespace_conformant, true}]), Assertion = decode_assertion(Doc), {ok, #esaml_assertion{attributes = Attrs}} = Assertion, - [{emailaddress, "test@test.com"}, {foo, ["george", "bar"]}, {mail, "test@test.com"}, {"foo",["george","bar"]}, {"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", "test@test.com"}, {"urn:oid:0.9.2342.19200300.100.1.3", "test@test.com"}] = lists:sort(Attrs). + [{emailaddress, ["test@test.com"]}, {foo, ["george", "bar"]}, {mail, ["test@test.com"]}, {"foo",["george","bar"]}, {"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", ["test@test.com"]}, {"urn:oid:0.9.2342.19200300.100.1.3", ["test@test.com"]}] = lists:sort(Attrs). decode_solicited_in_response_to_test() -> {Doc, _} = xmerl_scan:string("foofoofoobarfoobaraudience", [{namespace_conformant, true}]),