From: Florian Ragwitz Date: Sat, 26 Mar 2011 13:59:00 +0000 (+0100) Subject: The IIS 6 script name fix is now part of Plack X-Git-Tag: 5.89003~84 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=fb99321f925e4516003c21c502d363adbcb6df9e The IIS 6 script name fix is now part of Plack Depend on it and use it. --- diff --git a/Makefile.PL b/Makefile.PL index bad4bb5..ee5949d 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -54,7 +54,7 @@ requires 'MooseX::Getopt' => '0.30'; requires 'MooseX::Types'; requires 'MooseX::Types::Common::Numeric'; requires 'String::RewritePrefix' => '0.004'; # Catalyst::Utils::resolve_namespace -requires 'Plack' => '0.9935'; # Setup empty PATH_INFO if needed +requires 'Plack' => '0.9974'; # IIS6 fix middleware requires 'Plack::Middleware::ReverseProxy' => '0.04'; test_requires 'Class::Data::Inheritable'; diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index dcc8c2b..6c1ef1e 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -36,6 +36,7 @@ use Carp qw/croak carp shortmess/; use Try::Tiny; use Plack::Middleware::Conditional; use Plack::Middleware::ReverseProxy; +use Plack::Middleware::IIS6ScriptNameFix; BEGIN { require 5.008004; } @@ -2709,32 +2710,10 @@ sub _wrapped_legacy_psgi_app { }, ); - $psgi_app = Plack::Middleware::Conditional->wrap( - $psgi_app, - condition => $server_matches->(qr/IIS\/[6-9]\.[0-9]/), - builder => sub { - my ($to_wrap) = @_; - return sub { - my ($env) = @_; - - 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 $to_wrap->($env); - }; - }, - ); + # we're applying this unconditionally as the middleware itself already makes + # sure it doesn't fuck things up if it's not running under one of the right + # IIS versions + $psgi_app = Plack::Middleware::IIS6ScriptNameFix->wrap($psgi_app); return $psgi_app; }