Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Middleware::Lint rejects OPTIONS * special case #587

Open
daxim opened this issue Apr 26, 2017 · 0 comments
Open

Middleware::Lint rejects OPTIONS * special case #587

daxim opened this issue Apr 26, 2017 · 0 comments

Comments

@daxim
Copy link

daxim commented Apr 26, 2017

See https://tools.ietf.org/html/rfc7230#section-5.3.4,
https://tools.ietf.org/html/rfc7231#section-4.3.7.

The following patch (untested) restores compliance with the spec.

diff --git a/lib/Plack/Middleware/Lint.pm b/lib/Plack/Middleware/Lint.pm
index eb3deee..be422f5 100644
--- a/lib/Plack/Middleware/Lint.pm
+++ b/lib/Plack/Middleware/Lint.pm
@@ -42,7 +42,10 @@ sub validate_env {
        unless (defined($env->{PATH_INFO})) { # allows empty string
            die('Missing mandatory env param: PATH_INFO');
        }
-    if ($env->{PATH_INFO} ne '' && $env->{PATH_INFO} !~ m!^/!) {
+    if ($env->{PATH_INFO} ne '' && $env->{PATH_INFO} !~ m!^/! &&
+        !($env->{REQUEST_METHOD} eq 'OPTIONS' &&
+          $env->{REQUEST_URI} eq '*')
+    ) {
            die('PATH_INFO must begin with / ($env->{PATH_INFO})');
        }
        unless (defined($env->{SERVER_NAME})) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant