Escape pdata cookie value (#1461)
This fixes CI failure with Debian/stable
This commit is contained in:
parent
d49cfb5f69
commit
7b1fd1eae7
|
@ -14,6 +14,7 @@ our $VERSION = '2.0.0';
|
||||||
package Lemonldap::NG::Portal::Main;
|
package Lemonldap::NG::Portal::Main;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use URI::Escape;
|
||||||
|
|
||||||
# List constants
|
# List constants
|
||||||
sub authProcess { qw(extractFormInfo getUser authenticate) }
|
sub authProcess { qw(extractFormInfo getUser authenticate) }
|
||||||
|
@ -39,7 +40,7 @@ sub handler {
|
||||||
# Restore pdata
|
# Restore pdata
|
||||||
if ( my $v = $req->cookies->{ $self->conf->{cookieName} . 'pdata' } ) {
|
if ( my $v = $req->cookies->{ $self->conf->{cookieName} . 'pdata' } ) {
|
||||||
$sp = 1;
|
$sp = 1;
|
||||||
eval { $req->pdata( JSON::from_json($v) ); };
|
eval { $req->pdata( JSON::from_json( uri_unescape($v) ) ); };
|
||||||
if ($@) {
|
if ($@) {
|
||||||
$self->logger->error("Bad JSON content in cookie pdata");
|
$self->logger->error("Bad JSON content in cookie pdata");
|
||||||
$req->pdata( {} );
|
$req->pdata( {} );
|
||||||
|
@ -53,7 +54,7 @@ sub handler {
|
||||||
name => $self->conf->{cookieName} . 'pdata',
|
name => $self->conf->{cookieName} . 'pdata',
|
||||||
(
|
(
|
||||||
%{ $req->pdata }
|
%{ $req->pdata }
|
||||||
? ( value => JSON::to_json( $req->pdata ) )
|
? ( value => uri_escape( JSON::to_json( $req->pdata ) ) )
|
||||||
: ( value => '', expires => 'Wed, 21 Oct 2015 00:00:00 GMT' )
|
: ( value => '', expires => 'Wed, 21 Oct 2015 00:00:00 GMT' )
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use Test::More;
|
use Test::More;
|
||||||
use strict;
|
use strict;
|
||||||
use IO::String;
|
use IO::String;
|
||||||
|
use URI::Escape;
|
||||||
|
|
||||||
require 't/test-lib.pm';
|
require 't/test-lib.pm';
|
||||||
|
|
||||||
|
@ -19,15 +20,15 @@ my $client = LLNG::Manager::Test->new(
|
||||||
# Two simple access to see if pdata is set and restored
|
# Two simple access to see if pdata is set and restored
|
||||||
ok( $res = $client->_get( '/', ), 'Simple access' );
|
ok( $res = $client->_get( '/', ), 'Simple access' );
|
||||||
$tmp = expectCookie( $res, 'lemonldappdata' );
|
$tmp = expectCookie( $res, 'lemonldappdata' );
|
||||||
ok( $tmp eq '{"mytest":1}', 'Pdata is {"mytest":1}' )
|
ok( $tmp eq uri_escape('{"mytest":1}'), 'Pdata is {"mytest":1}' )
|
||||||
or explain( $tmp, '{"mytest":1}' );
|
or explain( $tmp, uri_escape('{"mytest":1}') );
|
||||||
count(2);
|
count(2);
|
||||||
|
|
||||||
ok( $res = $client->_get( '/', cookie => 'lemonldappdata={"mytest":1}', ),
|
ok( $res = $client->_get( '/', cookie => 'lemonldappdata=' . $tmp, ),
|
||||||
'Second simple access' );
|
'Second simple access' );
|
||||||
$tmp = expectCookie( $res, 'lemonldappdata' );
|
$tmp = expectCookie( $res, 'lemonldappdata' );
|
||||||
ok( $tmp eq '{"mytest":2}', 'Pdata is {"mytest":2}' )
|
ok( $tmp eq uri_escape('{"mytest":2}'), 'Pdata is {"mytest":2}' )
|
||||||
or explain( $tmp, '{"mytest":1}' );
|
or explain( $tmp, uri_escape('{"mytest":2}') );
|
||||||
count(2);
|
count(2);
|
||||||
|
|
||||||
# Try to authenticate
|
# Try to authenticate
|
||||||
|
|
Loading…
Reference in New Issue
Block a user