From fc204a4d6c07b5f65d119b76f4e6606f9df84d7a Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Tue, 31 Oct 2017 17:17:13 +0100
Subject: [PATCH] enforce strict and warnings pragmas

---
 lib/IdPAccountManager/WebRequest.pm | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm
index 02c96b3..84e7417 100755
--- a/lib/IdPAccountManager/WebRequest.pm
+++ b/lib/IdPAccountManager/WebRequest.pm
@@ -1,11 +1,18 @@
 package IdPAccountManager::WebRequest;
 
+use strict;
+use warnings;
+
 use IdPAccountManager::Logger;
 
 ## New web request
 sub new {
     my $pkg     = shift;
-    my $request = {};
+    my %args    = shift;
+    my $request = {
+        format  => $args{format},
+        actions => $args{actions},
+    };
 
     $request->{logger} = IdPAccountManager::Logger->new(
         file      => $Conf::global{'log_file'},
@@ -33,7 +40,7 @@ sub new {
     ## Usefull data for output (web pages or mail notices)
     $request->{'param_out'}{'url_cgi'} = $ENV{'SCRIPT_NAME'};
     $request->{'param_out'}{'env'}     = \%ENV;
-    $request->{'param_out'}{'actions'} = \%actions;
+    $request->{'param_out'}{'actions'} = $args{actions};
     $request->{'param_out'}{'conf'}    = \%Conf::global;
 
     ## Dumping input data
@@ -87,10 +94,10 @@ sub execute {
     ## Check input parameters format
     foreach my $key (keys %{ $self->{'param_in'} }) {
         if (   $self->{'param_in'}{$key} !~ /^\s*$/
-            && defined $format{$key}
-            && !ref($format{$key}))
+            && defined $self->{format}->{$key}
+            && !ref($self->{format}->{$key}))
         {
-            unless ($self->{'param_in'}{$key} =~ /^$format{$key}$/) {
+            unless ($self->{'param_in'}{$key} =~ /^$self->format->{$key}$/) {
                 push @{ $self->{'param_out'}{'errors'} }, "format_$key";
                 $self->{logger}->log(
                     level   => LOG_ERROR,
@@ -106,7 +113,7 @@ sub execute {
         $self->{'action'} = $self->{'next_action'} if ($self->{'next_action'});
         delete $self->{'next_action'};    ## Prevent loops
 
-        if (defined $actions{ $self->{'action'} }) {
+        if (defined $self->actions->{ $self->{'action'} }) {
             ## Execute the target subroutine named req_actionName
             no strict 'refs';
             my $sub = 'req_' . $self->{'action'};
@@ -576,7 +583,7 @@ sub req_validate_token {
     }
 
     ## Update simpleSAMLphp configuration to enable test accounts
-    unless (IdPAccountManager::Tools::update_ssp_authsources() {
+    unless (IdPAccountManager::Tools::update_ssp_authsources()) {
         push @{ $self->{'param_out'}{'errors'} }, "accounts_creation_failed";
         $self->{logger}->log(
             level   => LOG_ERROR,
-- 
GitLab