@@ -377,7 +377,7 @@ def get_audiences(self):
377377 :rtype: list
378378 """
379379 audience_nodes = self .__query_assertion ('/saml:Conditions/saml:AudienceRestriction/saml:Audience' )
380- return [node . text for node in audience_nodes if node . text is not None ]
380+ return [OneLogin_Saml2_Utils . element_text ( node ) for node in audience_nodes if OneLogin_Saml2_Utils . element_text ( node ) is not None ]
381381
382382 def get_issuers (self ):
383383 """
@@ -391,7 +391,7 @@ def get_issuers(self):
391391 message_issuer_nodes = OneLogin_Saml2_Utils .query (self .document , '/samlp:Response/saml:Issuer' )
392392 if len (message_issuer_nodes ) > 0 :
393393 if len (message_issuer_nodes ) == 1 :
394- issuers .append (message_issuer_nodes [0 ]. text )
394+ issuers .append (OneLogin_Saml2_Utils . element_text ( message_issuer_nodes [0 ]) )
395395 else :
396396 raise OneLogin_Saml2_ValidationError (
397397 'Issuer of the Response is multiple.' ,
@@ -400,7 +400,7 @@ def get_issuers(self):
400400
401401 assertion_issuer_nodes = self .__query_assertion ('/saml:Issuer' )
402402 if len (assertion_issuer_nodes ) == 1 :
403- issuers .append (assertion_issuer_nodes [0 ]. text )
403+ issuers .append (OneLogin_Saml2_Utils . element_text ( assertion_issuer_nodes [0 ]) )
404404 else :
405405 raise OneLogin_Saml2_ValidationError (
406406 'Issuer of the Assertion not found or multiple.' ,
@@ -438,13 +438,13 @@ def get_nameid_data(self):
438438 OneLogin_Saml2_ValidationError .NO_NAMEID
439439 )
440440 else :
441- if is_strict and want_nameid and not nameid . text :
441+ if is_strict and want_nameid and not OneLogin_Saml2_Utils . element_text ( nameid ) :
442442 raise OneLogin_Saml2_ValidationError (
443443 'An empty NameID value found' ,
444444 OneLogin_Saml2_ValidationError .EMPTY_NAMEID
445445 )
446446
447- nameid_data = {'Value' : nameid . text }
447+ nameid_data = {'Value' : OneLogin_Saml2_Utils . element_text ( nameid ) }
448448 for attr in ['Format' , 'SPNameQualifier' , 'NameQualifier' ]:
449449 value = nameid .get (attr , None )
450450 if value :
@@ -541,18 +541,19 @@ def get_attributes(self):
541541 for attr in attribute_node .iterchildren ('{%s}AttributeValue' % OneLogin_Saml2_Constants .NSMAP [OneLogin_Saml2_Constants .NS_PREFIX_SAML ]):
542542 # Remove any whitespace (which may be present where attributes are
543543 # nested inside NameID children).
544- if attr .text :
545- text = attr .text .strip ()
546- if text :
547- values .append (text )
544+ attr_text = OneLogin_Saml2_Utils .element_text (attr )
545+ if attr_text :
546+ attr_text = attr_text .strip ()
547+ if attr_text :
548+ values .append (attr_text )
548549
549550 # Parse any nested NameID children
550551 for nameid in attr .iterchildren ('{%s}NameID' % OneLogin_Saml2_Constants .NSMAP [OneLogin_Saml2_Constants .NS_PREFIX_SAML ]):
551552 values .append ({
552553 'NameID' : {
553554 'Format' : nameid .get ('Format' ),
554555 'NameQualifier' : nameid .get ('NameQualifier' ),
555- 'value' : nameid . text
556+ 'value' : OneLogin_Saml2_Utils . element_text ( nameid )
556557 }
557558 })
558559
0 commit comments