Skip to content

Commit

Permalink
Issue #581: work with relative path, avoid issues with proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
bschmalhofer committed Oct 27, 2020
1 parent c06f45a commit 7c19051
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions bin/psgi-bin/otobo.psgi
Original file line number Diff line number Diff line change
Expand Up @@ -490,19 +490,25 @@ my $DumpEnvApp = sub {
];
};

# handler for /otobo
# Redirect to otobo/index.pl when in doubt, no permission check
# Handler andler for 'otobo', 'otobo/', 'otobo/not_existent', 'otobo/some/thing' and such.
# Would also work for /dummy if mounted accordingly.
# Redirect via a relative URL to otobo/index.pl.
# No permission check,
my $RedirectOtoboApp = sub {
my $Env = shift;

my $req = Plack::Request->new($Env);
my $uri = $req->base;
$uri->path($uri->path . '/index.pl');
# construct a relative path to otobo/index.pl
my $Req = Plack::Request->new($Env);
my $OrigPath = $Req->path;
my $Levels = $OrigPath =~ tr[/][];
my $NewPath = join '/', map( { '..' } ( 1 .. $Levels ) ), 'otobo/index.pl';

my $res = Plack::Response->new();
$res->redirect($uri);
# redirect
my $Res = Plack::Response->new();
$Res->redirect($NewPath);

return $res->finalize;
# send the PSGI response
return $Res->finalize;
};

# an App for inspecting the database, logged in user must be an admin
Expand Down

0 comments on commit 7c19051

Please sign in to comment.