@@ -71,10 +71,7 @@ def is_valid?(collect_errors = false)
7171 # @return [String] the NameID provided by the SAML response from the IdP.
7272 #
7373 def name_id
74- @name_id ||=
75- if name_id_node
76- name_id_node . text
77- end
74+ @name_id ||= Utils . element_text ( name_id_node )
7875 end
7976
8077 alias_method :nameid , :name_id
@@ -159,14 +156,14 @@ def attributes
159156 if ( e . elements . nil? || e . elements . size == 0 )
160157 # SAMLCore requires that nil AttributeValues MUST contain xsi:nil XML attribute set to "true" or "1"
161158 # otherwise the value is to be regarded as empty.
162- [ "true" , "1" ] . include? ( e . attributes [ 'xsi:nil' ] ) ? nil : e . text . to_s
159+ [ "true" , "1" ] . include? ( e . attributes [ 'xsi:nil' ] ) ? nil : Utils . element_text ( e )
163160 # explicitly support saml2:NameID with saml2:NameQualifier if supplied in attributes
164161 # this is useful for allowing eduPersonTargetedId to be passed as an opaque identifier to use to
165162 # identify the subject in an SP rather than email or other less opaque attributes
166163 # NameQualifier, if present is prefixed with a "/" to the value
167164 else
168165 REXML ::XPath . match ( e , 'a:NameID' , { "a" => ASSERTION } ) . collect { |n |
169- ( n . attributes [ 'NameQualifier' ] ? n . attributes [ 'NameQualifier' ] +"/" : '' ) + n . text . to_s
166+ ( n . attributes [ 'NameQualifier' ] ? n . attributes [ 'NameQualifier' ] +"/" : '' ) + Utils . element_text ( n )
170167 }
171168 end
172169 }
@@ -238,8 +235,7 @@ def status_message
238235 { "p" => PROTOCOL }
239236 )
240237 if nodes . size == 1
241- node = nodes [ 0 ]
242- node . text if node
238+ Utils . element_text ( nodes . first )
243239 end
244240 end
245241 end
@@ -272,7 +268,6 @@ def not_on_or_after
272268 #
273269 def issuers
274270 @issuers ||= begin
275- issuers = [ ]
276271 issuer_response_nodes = REXML ::XPath . match (
277272 document ,
278273 "/p:Response/a:Issuer" ,
@@ -292,10 +287,7 @@ def issuers
292287 end
293288
294289 nodes = issuer_response_nodes + issuer_assertion_nodes
295- nodes . each do |node |
296- issuers << node . text if node . text
297- end
298- issuers . uniq
290+ nodes . map { |node | Utils . element_text ( node ) } . compact . uniq
299291 end
300292 end
301293
@@ -329,14 +321,8 @@ def destination
329321 #
330322 def audiences
331323 @audiences ||= begin
332- audiences = [ ]
333324 nodes = xpath_from_signed_assertion ( '/a:Conditions/a:AudienceRestriction/a:Audience' )
334- nodes . each do |node |
335- if node && node . text
336- audiences << node . text
337- end
338- end
339- audiences
325+ nodes . map { |node | Utils . element_text ( node ) } . compact
340326 end
341327 end
342328
0 commit comments