plack / Plack

PSGI toolkit and server adapters
http://plackperl.org/
Other
486 stars 214 forks source link

Please update Plack::Middleware::IIS6ScriptNameFix to work on IIS 10.0 #679

Closed tonytronics closed 2 years ago

tonytronics commented 2 years ago

With the release of IIS 10 on Windows 2019 Catalyst Apps running as FastCGI apps in IIS are being left out of this fix. The fix covers IIS 6 to 8.5 but is excluded from running in IIS 10. Note: IIS 10 requires the update to PATH_INFO and SCRIPT_NAME *The code used to filter Server_Software needs to include IIS/10.0

miyagawa commented 2 years ago

rather than updating the regexp, I made a new option force which would skip the SERVER_SOFTWARE regexp match.

tonytronics commented 2 years ago

Tatsuhiko Can you let me know how to use the force option in my Catalyst application.

(Tony Okusanya)

On Aug 31, 2022, at 7:17 PM, Tatsuhiko Miyagawa @.***> wrote:

 Closed #679 as completed via ef1785d.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

miyagawa commented 2 years ago

locate .psgi file of your application and add or update:

enable "IIS6ScriptNameFix", force => 1;
tonytronics commented 2 years ago

Greetings Miyagawa and thanks for responding to this. I am a bit confused as to how the force option works here for Plack::Middleware::IIS6ScriptNameFix as the call to the sub “call” will not run on Microsoft IIS 10 as the SERVERSOFTWARE environment variable in IIS 10 shows up as IIS/10.0. THe current code works with IIS 6,7.5,8,8.5 sub call { my($self, $env) = @;

if ($env->{SERVER_SOFTWARE} && $env->{SERVER_SOFTWARE} =~ /IIS\/[6-9]\.[0-9]/) {
    my @script_name = split(m!/!, $env->{PATH_INFO});
    my @path_translated = split(m!/|\\\\?!, $env->{PATH_TRANSLATED});
    my @path_info;

    while ($script_name[$#script_name] eq $path_translated[$#path_translated]) {
        pop(@path_translated);
        unshift(@path_info, pop(@script_name));
    }

    unshift(@path_info, '', '');

    $env->{PATH_INFO} = join('/', @path_info);
    $env->{SCRIPT_NAME} = join('/', @script_name);
}

return $self->app->($env);

}

miyagawa commented 2 years ago

the fix is in the master branch on github via https://github.com/plack/Plack/commit/ef1785d838c94ddb917dfa6af3bd68ca71d589a6 and not on CPAN yet.

Meanwhile, you can grab it from GitHub, or copy the content of IIS6ScriptNameFix to your own .pm file and enable it rather than waiting for a fix upstream.

miyagawa commented 2 years ago

I released 1.0049 to CPAN.