Commit 3761cb68 authored by IKEDA Soji's avatar IKEDA Soji
Browse files

Refactoring. Don't use REQUEST_URI but use SCRIPT_NAME, PATH_INFO and QUERY_STRING.

parent f71abf8d
......@@ -3861,7 +3861,7 @@ sub do_help {
# Strip extensions.
$in{'help_topic'} =~ s/[.].*// if $in{'help_topic'};
# Given partial top URI, redirect to base.
unless ($in{'help_topic'} or $ENV{REQUEST_URI} =~ /\/\z/) {
unless ($in{'help_topic'} or ($ENV{PATH_INFO} // '') =~ m{/\z}) {
$param->{'redirect_to'} = Sympa::get_url(
$list, 'help',
nomenu => $param->{'nomenu'},
......@@ -8659,7 +8659,7 @@ sub do_arc {
);
return 1;
}
unless ($in{'arc_file'} or $ENV{REQUEST_URI} =~ /\/\z/) {
unless ($in{'arc_file'} or ($ENV{PATH_INFO} // '') =~ m{/\z}) {
$param->{'redirect_to'} = Sympa::get_url(
$list, 'arc',
nomenu => $param->{'nomenu'},
......
......@@ -202,26 +202,14 @@ sub get_my_url {
my $robot = shift;
my %options = @_;
my $original_path_info;
# Try getting encoded PATH_INFO and query.
my $request_uri = $ENV{REQUEST_URI} || '';
my $script_name = $ENV{SCRIPT_NAME} || '';
if ( $request_uri eq $script_name
or 0 == index($request_uri, $script_name . '?')
or 0 == index($request_uri, $script_name . '/')) {
$original_path_info = substr($request_uri, length $script_name);
} else {
# Workaround: Encode PATH_INFO again and use it.
my $path_info = $ENV{PATH_INFO} || '';
my $query_string = $ENV{QUERY_STRING};
$original_path_info =
Sympa::Tools::Text::encode_uri($path_info, omit => '/')
. ($query_string ? ('?' . $query_string) : '');
}
my $path_info = $ENV{PATH_INFO} // '';
my $query_string = $ENV{QUERY_STRING} // '';
return Sympa::get_url($robot, undef, authority => $options{authority})
. $original_path_info;
return
Sympa::get_url($robot, undef, authority => $options{authority})
. Sympa::Tools::Text::encode_uri($path_info, omit => '/')
. (length $query_string ? '?' : '')
. $query_string;
}
# Determine robot.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment