Do not use arrays in REST sessions (#2190)

This commit is contained in:
Clément OUDOT 2020-05-12 16:05:22 +02:00
parent 3385fc3ae2
commit 3ebbfae7c6
3 changed files with 5 additions and 10 deletions

View File

@ -5,7 +5,7 @@ use Mouse;
use Lemonldap::NG::Common::Conf::Constants;
use JSON qw(from_json to_json);
our $VERSION = '2.0.8';
our $VERSION = '2.0.9';
has sessionTypes => ( is => 'rw' );
@ -219,16 +219,11 @@ sub _session {
my $apacheSession = $self->getApacheSession( $mod, $id )
or return $self->sendError( $req, undef, 400 );
my %session = %{ $apacheSession->data };
my %session = %{ $apacheSession->data };
unless ($raw) {
my $separator = $self->separator();
foreach my $k ( keys %session ) {
$session{$k} = '**********'
if ( $self->hAttr =~ /\b$k\b/ );
if ( $session{$k} =~ /$separator/ ) {
$self->logger->debug("Convert \"$k\" value to array");
$session{$k} = [ split /$separator/, $session{$k} ];
}
}
}

View File

@ -145,7 +145,7 @@ ok( $res = eval { JSON::from_json( $res->[2]->[0] ) }, ' GET JSON' )
or print STDERR $@;
ok( $res->{cn} eq 'Frédéric Accents', 'UTF-8 values' )
or explain( $res, 'cn => Frédéric Accents' );
ok( ref( $res->{multi} ) eq "ARRAY" and $res->{multi}->[0] =~ /value/ )
ok( $res->{multi} =~ /value1;value2/ )
or explain( $res->{multi}, 'Multi valued attribute' );
count(4);

View File

@ -101,8 +101,8 @@ ok( $res = eval { JSON::from_json( $res->[2]->[0] ) }, ' GET JSON' )
or print STDERR $@;
ok( $res->{_session_id} eq $spId, ' Good ID' )
or explain( $res, "_session_id => $spId" );
ok( ref $res->{array} eq 'ARRAY', ' Array ref found' )
or explain( $res, "array => Ref" );
ok( $res->{array} =~ /;/, 'Mulivalued attribute found' )
or explain( $res, "Multivalued attribute" );
count(4);
# Session key