Permalink
Browse files

localize PATH_INFO and SCRIPT_NAME in env when locating a file. Fixes g…

  • Loading branch information...
1 parent 7e8531b commit cf0ea5a9b9a76fe5d43d14ae45a0cf4cafba86e1 @miyagawa miyagawa committed May 5, 2010
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/Plack/App/File.pm
View
6 lib/Plack/App/File.pm
@@ -22,13 +22,15 @@ sub call {
my($file, $path_info) = $self->file || $self->locate_file($env);
return $file if ref $file eq 'ARRAY';
+ local @{$env}{qw( SCRIPT_NAME PATH_INFO )} = @{$env}{qw( SCRIPT_NAME PATH_INFO )};
+
if ($path_info) {
$env->{PATH_INFO} =~ s/\Q$path_info\E$//;
$env->{SCRIPT_NAME} = $env->{SCRIPT_NAME} . $env->{PATH_INFO};
- $env->{PATH_INFO } = $path_info;
+ $env->{PATH_INFO} = $path_info;
} else {
$env->{SCRIPT_NAME} = $env->{SCRIPT_NAME} . $env->{PATH_INFO};
- $env->{PATH_INFO } = '';
+ $env->{PATH_INFO} = '';
}
return $self->serve_path($env, $file);

0 comments on commit cf0ea5a

Please sign in to comment.