Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Plack/Middleware/Lint.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sub validate_env {
unless ($env->{REQUEST_METHOD}) {
die('Missing env param: REQUEST_METHOD');
}
unless ($env->{REQUEST_METHOD} =~ /^[A-Z]+$/) {
unless ($env->{REQUEST_METHOD} =~ /^[A-Za-z0-9!#\$%&'*+\-.^_`|~]+$/) {
die("Invalid env param: REQUEST_METHOD($env->{REQUEST_METHOD})");
}
unless (defined($env->{SCRIPT_NAME})) { # allows empty string
Expand Down
6 changes: 5 additions & 1 deletion t/Plack-Middleware/lint_env.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ $app = Plack::Middleware::Lint->wrap($app);

my @good_env = (
{ PATH_INFO => '' },
{ REQUEST_METHOD => 'get' },
{ REQUEST_METHOD => 'GeT' },
{ REQUEST_METHOD => 'my-custom-method' },
);

my @bad_env = (
[ { REQUEST_METHOD => undef }, qr/Missing env param: REQUEST_METHOD/ ],
[ { REQUEST_METHOD => "foo" },, qr/Invalid env param: REQUEST_METHOD/ ],
[ { REQUEST_METHOD => "foo bar" }, qr/Invalid env param: REQUEST_METHOD/ ],
[ { REQUEST_METHOD => "" }, qr/Missing env param: REQUEST_METHOD/ ],
[ { PATH_INFO => 'foo' }, qr/PATH_INFO must begin with \// ],
[ { SERVER_PORT => undef }, qr/Missing mandatory .*SERVER_PORT/ ],
[ { SERVER_PROTOCOL => 'HTTP/x' }, qr/Invalid SERVER_PROTOCOL/ ],
Expand Down