Escape values in URI (#1025)

This commit is contained in:
Clément Oudot 2016-06-06 09:51:12 +00:00
parent a8ecd8f76a
commit 7be4088df1

View File

@ -9,9 +9,10 @@ package Lemonldap::NG::Portal::IssuerDBGet;
use strict; use strict;
use Lemonldap::NG::Portal::Simple; use Lemonldap::NG::Portal::Simple;
use MIME::Base64; use MIME::Base64;
use URI::Escape;
use base qw(Lemonldap::NG::Portal::_LibAccess); use base qw(Lemonldap::NG::Portal::_LibAccess);
our $VERSION = '1.9.3'; our $VERSION = '2.0.0';
## @method void issuerDBInit() ## @method void issuerDBInit()
# Nothing to do # Nothing to do
@ -74,7 +75,6 @@ sub issuerForUnAuthUser {
return PE_OK; return PE_OK;
} }
## @apmethod int issuerForAuthUser() ## @apmethod int issuerForAuthUser()
# Manage Get request for authenticated user # Manage Get request for authenticated user
# @return Lemonldap::NG::Portal error code # @return Lemonldap::NG::Portal error code
@ -170,6 +170,7 @@ sub computeGetParams {
if ( exists $self->{issuerDBGetParameters} ) { if ( exists $self->{issuerDBGetParameters} ) {
my $issuerDBGetParameters = $self->{issuerDBGetParameters}; my $issuerDBGetParameters = $self->{issuerDBGetParameters};
foreach my $vhost ( keys %$issuerDBGetParameters ) { foreach my $vhost ( keys %$issuerDBGetParameters ) {
# if vhost is matching # if vhost is matching
if ( index( $self->{urldc}, $vhost ) != -1 ) { if ( index( $self->{urldc}, $vhost ) != -1 ) {
my $params = $issuerDBGetParameters->{$vhost}; my $params = $issuerDBGetParameters->{$vhost};
@ -184,8 +185,10 @@ sub computeGetParams {
$value = eval($val); $value = eval($val);
$self->lmLog( "Error while evaluating $val: $@", 'warn' ) $self->lmLog( "Error while evaluating $val: $@", 'warn' )
if $@; if $@;
# Chain GET parameters unless there are evaluation errors # Chain GET parameters unless there are evaluation errors
$getVars .= "&".$param."=".$value unless $@; $getVars .= "&" . $param . "=" . uri_escape($value)
unless $@;
} }
} }
} }
@ -198,10 +201,13 @@ sub computeGetParams {
if ( $getVars ne "" ) { if ( $getVars ne "" ) {
my $urldc = $self->{urldc}; my $urldc = $self->{urldc};
$urldc .= ( $urldc =~ /\?\w/ ) ? $urldc .= ( $urldc =~ /\?\w/ )
?
# there are already get variables # there are already get variables
"&" . $getVars "&" . $getVars
: :
# there are no get variables # there are no get variables
"?" . $getVars; "?" . $getVars;
$self->{urldc} = $urldc; $self->{urldc} = $urldc;
@ -209,7 +215,6 @@ sub computeGetParams {
} }
sub substitute { sub substitute {
my $expr = shift; my $expr = shift;
@ -224,10 +229,6 @@ sub substitute {
return $expr; return $expr;
} }
1; 1;
__END__ __END__