From b8fe9aaafae32cb03eb81d2f05072477699f4695 Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Fri, 3 Nov 2017 15:02:55 +0100
Subject: [PATCH] fix some undefined string warnings

---
 lib/IdPAccountManager/SAMLMetadata.pm | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/lib/IdPAccountManager/SAMLMetadata.pm b/lib/IdPAccountManager/SAMLMetadata.pm
index 53a45fc..e4c455b 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;
 }
 
-- 
GitLab