Fix vhost regexp (#2477)

This commit is contained in:
Yadd 2021-03-02 07:57:21 +01:00
parent fd3b2d25ef
commit 3883c5abff
2 changed files with 33 additions and 3 deletions

View File

@ -57,8 +57,9 @@ sub processHook {
$self->logger->debug("Not a code ref: $sub");
}
}
if ($err != PE_OK) {
$self->logger->warn("Hook $hookName returned ".portalConsts->{$err});
if ( $err != PE_OK ) {
$self->logger->warn(
"Hook $hookName returned " . portalConsts->{$err} );
}
return $err;
}
@ -155,7 +156,7 @@ sub controlUrl {
}
# Unprotected hosts
my ( $proto, $vhost, $appuri ) = $tmp =~ m#^(https?://)([^/]*)(.*)#;
my ( $proto, $vhost, $appuri ) = $tmp =~ m{^(https?://)([^/#?]*)(.*)};
$vhost =~ s/:\d+$//;
# Try to resolve alias

View File

@ -0,0 +1,29 @@
use Test::More;
use strict;
use IO::String;
use MIME::Base64;
require 't/test-lib.pm';
my $res;
my $client = LLNG::Manager::Test->new(
{ ini => { logLevel => 'debug', useSafeJail => 1 } } );
ok(
$res = $client->_get(
'/',
query => 'url='
. encode_base64( 'http://bad.com#test.example.llng', '' )
),
'Try http://bad.com#test.example.llng'
);
expectReject($res);
ok( $res->[2]->[0] =~ /37/, 'Rejected with PE_BADURL' )
or print STDERR Dumper( $res->[2]->[0] );
count(2);
clean_sessions();
done_testing( count() );