X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Controller-WrapCGI.git;a=blobdiff_plain;f=lib%2FCatalyst%2FController%2FWrapCGI.pm;h=262e960025b190fc51d0d1ede00e24273af698a6;hp=11f2fe76acae586d0cec72aa6786e8cc3e45d3ac;hb=f410f043b41cc59d08cb1aa015378888c8fe88b7;hpb=f07403fe54b0b8d92f80bd33c8ac9891d325f80a diff --git a/lib/Catalyst/Controller/WrapCGI.pm b/lib/Catalyst/Controller/WrapCGI.pm index 11f2fe7..262e960 100644 --- a/lib/Catalyst/Controller/WrapCGI.pm +++ b/lib/Catalyst/Controller/WrapCGI.pm @@ -9,6 +9,9 @@ use HTTP::Request::AsCGI (); use HTTP::Request (); use URI (); use Catalyst::Exception (); +use URI::Escape; + +use namespace::clean -except => 'meta'; =head1 NAME @@ -91,12 +94,14 @@ open my $REAL_STDOUT, ">>&=".fileno(*STDOUT); =head1 METHODS -=head2 $self->cgi_to_response($c, $coderef) +=head2 cgi_to_response + +C<<$self->cgi_to_response($c, $coderef)>> Does the magic of running $coderef in a CGI environment, and populating the appropriate parts of your Catalyst context with the results. -Calls wrap_cgi (below.) +Calls L. =cut @@ -119,7 +124,9 @@ sub cgi_to_response { $c->res->headers($res->headers); } -=head2 $self->wrap_cgi($c, $coderef) +=head2 wrap_cgi + +C<<$self->wrap_cgi($c, $coderef)>> Runs $coderef in a CGI environment using L, returns an L. @@ -130,7 +137,7 @@ The environment variables to pass on are taken from the configuration for your Controller, see L for an example. If you don't supply a list of environment variables to pass, the whole of %ENV is used. -Used by cgi_to_response (above), which is probably what you want to use as well. +Used by L, which is probably what you want to use as well. =cut @@ -167,13 +174,15 @@ sub wrap_cgi { ? eval { $c->user->obj->$username_field } : ''); - my $path_info = '/'.join '/' => @{ $c->req->args }; + my $path_info = '/'.join '/' => map uri_escape_utf8($_), @{ $c->req->args }; my $env = HTTP::Request::AsCGI->new( $req, ($username ? (REMOTE_USER => $username) : ()), %$filtered_env, - PATH_INFO => $path_info + PATH_INFO => $path_info, + FILEPATH_INFO => '/'.$c->action.$path_info, # eww + SCRIPT_NAME => $c->uri_for($c->action)->path ); { @@ -235,6 +244,7 @@ sub _filtered_env { return { map {; $_ => $env->{$_} } @ok }; } +__PACKAGE__->meta->make_immutable; =head1 ACKNOWLEDGEMENTS