Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ALlow an empty PATH_INFO per PSGI #349

  • Loading branch information...
commit b9d54a247b885f8bb9c6b17f988654f7bffda160 1 parent 40f7d02
Tatsuhiko Miyagawa miyagawa authored
Showing with 14 additions and 2 deletions.
  1. +2 −2 lib/Plack/Middleware/Lint.pm
  2. +12 −0 t/Plack-Middleware/lint_env.t
4 lib/Plack/Middleware/Lint.pm
View
@@ -42,8 +42,8 @@ sub validate_env {
unless (defined($env->{PATH_INFO})) { # allows empty string
die('Missing mandatory env param: PATH_INFO');
}
- if ($env->{PATH_INFO} !~ m!^/!) {
- die('PATH_INFO must begin with / ($env->{SCRIPT_NAME})');
+ if ($env->{PATH_INFO} ne '' && $env->{PATH_INFO} !~ m!^/!) {
+ die('PATH_INFO must begin with / ($env->{PATH_INFO})');
}
unless (defined($env->{SERVER_NAME})) {
die('Missing mandatory env param: SERVER_NAME');
12 t/Plack-Middleware/lint_env.t
View
@@ -11,6 +11,10 @@ my $app = sub {
$app = Plack::Middleware::Lint->wrap($app);
+my @good_env = (
+ { PATH_INFO => '' },
+);
+
my @bad_env = (
[ { REQUEST_METHOD => undef }, qr/Missing env param: REQUEST_METHOD/ ],
[ { REQUEST_METHOD => "foo" },, qr/Invalid env param: REQUEST_METHOD/ ],
@@ -21,6 +25,14 @@ my @bad_env = (
[ { HTTP_CONTENT_TYPE => "text/plain" }, qr/HTTP_CONTENT_TYPE should not exist/ ],
);
+for my $good (@good_env) {
+ my $env = req_to_psgi( HTTP::Request->new(GET => "/") );
+ eval {
+ $app->({ %$env, %$good });
+ };
+ ok !$@;
+}
+
for my $bad (@bad_env) {
my($inject, $err) = @$bad;
my $env = req_to_psgi( HTTP::Request->new(GET => "/") );
Please sign in to comment.
Something went wrong with that request. Please try again.