From: Tomas Doran Date: Thu, 28 Jan 2010 15:47:31 +0000 (+0000) Subject: Fix paths with URI encoding as the first path part X-Git-Tag: 5.80019~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=f54950f51a3f07623b26ddfa20257e70a67bb404 Fix paths with URI encoding as the first path part --- diff --git a/Changes b/Changes index d2d16d6..7832e73 100644 --- a/Changes +++ b/Changes @@ -12,6 +12,9 @@ an action object has been fixed to not just encode the first slash in any set of args/captures. + - nginx and lighttpd FCGI requests with URI encoded sections as the first + path part have been fixed to operate correctly. + New features: - Allow passing additional arguments to action constructors. diff --git a/lib/Catalyst/Engine/CGI.pm b/lib/Catalyst/Engine/CGI.pm index 1443a2f..4c0d9b9 100644 --- a/lib/Catalyst/Engine/CGI.pm +++ b/lib/Catalyst/Engine/CGI.pm @@ -168,7 +168,8 @@ sub prepare_path { if (substr($req_uri, 0, 1) ne '/') { my ($match) = $req_uri =~ m|^([^/]+)|; my ($path_info_part) = $path_info =~ m|^(.*?\Q$match\E)|; - substr($req_uri, 0, length($match), $path_info_part); + substr($req_uri, 0, length($match), $path_info_part) + if $path_info_part; } $path_info = $req_uri; } diff --git a/t/aggregate/unit_core_engine_cgi-prepare_path.t b/t/aggregate/unit_core_engine_cgi-prepare_path.t index f8b08ef..22081ff 100644 --- a/t/aggregate/unit_core_engine_cgi-prepare_path.t +++ b/t/aggregate/unit_core_engine_cgi-prepare_path.t @@ -62,7 +62,17 @@ use Catalyst::Engine::CGI; is ''.$r->base, 'http://www.foo.com/'; } - +# nginx example from espent with path /"foo" +{ + my $r = get_req ( + PATH_INFO => '"foo"', + SCRIPT_NAME => '/', + REQUEST_URI => '/%22foo%22', + ); + is ''.$r->path, '%22foo%22'; + is ''.$r->uri, 'http://www.foo.com/%22foo%22'; + is ''.$r->base, 'http://www.foo.com/'; +} # FIXME - Test proxy logic # - Test query string