diff --git a/lib/IdPAccountManager/SAMLMetadata.pm b/lib/IdPAccountManager/SAMLMetadata.pm index 53a45fc3cf97cee0961fb4bfd058187d62aa8c89..e4c455bf305ff80893066fc850b410e57767c6a1 100644 --- a/lib/IdPAccountManager/SAMLMetadata.pm +++ b/lib/IdPAccountManager/SAMLMetadata.pm @@ -130,14 +130,15 @@ sub parse { $data->{registration_info} {registration_instant} = $registrationinfo->getAttribute('registrationInstant'); - foreach my $registrationpolicy ( + foreach my $policy ( $registrationinfo->getElementsByLocalName( 'RegistrationPolicy') ) { - if ($registrationpolicy->getAttribute('lang') eq 'en') { + my $lang = $policy->getAttribute('lang'); + if ($lang && $lang eq 'en') { $data->{registration_info}->{registration_policy} = - $registrationpolicy->textContent(); + $policy->textContent(); } } } @@ -146,7 +147,8 @@ sub parse { $contact_details{type} = $child->getAttribute('contactType'); if (defined $contact_details{type}) { foreach my $contact_child ($child->childNodes()) { - $contact_details{ $contact_child->localName } = + next unless $contact_child->nodeType() == XML_ELEMENT_NODE; + $contact_details{ $contact_child->localname() } = $contact_child->textContent(); } push @{ $data->{contacts} }, \%contact_details; @@ -231,8 +233,9 @@ sub print { sub _boolean2integer { return - $_[0] eq 'true' ? 1 : - $_[0] eq 'false' ? 0 : + ! defined $_[0] ? undef : + $_[0] eq 'true' ? 1 : + $_[0] eq 'false' ? 0 : undef; }