From 47068c51b8fd2fda4d41ebe71c7a78a1bb6f345f Mon Sep 17 00:00:00 2001 From: Maxime Besson Date: Thu, 20 Feb 2020 22:14:38 +0100 Subject: [PATCH] Revert "Prevent portal from crashing when keepPdata=1 (#1893)" This reverts commit 2b4defb2a9df7bbbbb5a445bf9139113a76f7170 and implements a fix "at the source" instead. Should fix #2099. --- lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm | 6 +----- .../lib/Lemonldap/NG/Portal/Main/Process.pm | 5 +---- lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm | 7 +++++++ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm index 0272e75b5..ddb52931d 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm @@ -356,11 +356,7 @@ sub reloadConf { # Clean $req->pdata after authentication push @{ $self->endAuth }, sub { - - my $tmp = - ( ref( $_[0]->pdata->{keepPdata} ) eq 'ARRAY' ) - ? $_[0]->pdata->{keepPdata} - : []; + my $tmp = $_[0]->pdata->{keepPdata} //= []; foreach my $k ( keys %{ $_[0]->pdata } ) { unless ( grep { $_ eq $k } @$tmp ) { $self->logger->debug("Removing $k from pdata"); diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Process.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Process.pm index f73887179..c30a28f97 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Process.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Process.pm @@ -162,10 +162,7 @@ sub authLogout { my ( $self, $req ) = @_; my $res = $self->_authentication->authLogout($req); $self->logger->debug('Cleaning pdata'); - my $tmp = - ( ref( $req->pdata->{keepPdata} ) eq 'ARRAY' ) - ? $req->pdata->{keepPdata} - : []; + my $tmp = $req->pdata->{keepPdata} //= []; foreach my $k ( keys %{ $req->pdata } ) { delete $req->pdata->{$k} unless ( grep { $_ eq $k } @$tmp ); } diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm index 7c42a31be..3f479d13a 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm @@ -63,6 +63,13 @@ sub handler { $self->logger->error("Bad JSON content in cookie pdata"); $req->pdata( {} ); } + + # Avoid fatal errors when using old keepPdata format + if ( $req->pdata->{keepPdata} + and not( ref $req->pdata->{keepPdata} eq "ARRAY" ) ) + { + $req->pdata->{keepPdata} = []; + } } my $res = $self->Lemonldap::NG::Common::PSGI::Router::handler($req);