X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=b7f57fd47492cba06f9bc25fa42d48484d3ae8df;hb=eff5194d244746fc1486410d9a533e15ef07baf7;hp=509585f218c4dcdc9814e0fa67ae24484945a2ea;hpb=671123ba662cd4d38ee2590baad2b9f46947cb4e;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 509585f..b7f57fd 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -10,10 +10,12 @@ use HTML::Entities; use HTTP::Body; use HTTP::Headers; use URI::QueryParam; +use Encode (); +use utf8; use namespace::clean -except => 'meta'; -has env => (is => 'rw'); +has env => (is => 'rw', writer => '_set_env'); # input position and length has read_length => (is => 'rw'); @@ -91,6 +93,11 @@ sub finalize_cookies { -httponly => $val->{httponly} || 0, ) ); + if (!defined $cookie) { + $c->log->warn("undef passed in '$name' cookie value - not setting cookie") + if $c->debug; + next; + } push @cookies, $cookie->as_string; } @@ -131,6 +138,14 @@ sub finalize_error { $c->res->content_type('text/html; charset=utf-8'); my $name = ref($c)->config->{name} || join(' ', split('::', ref $c)); + + # Prevent Catalyst::Plugin::Unicode::Encoding from running. + # This is a little nasty, but it's the best way to be clean whether or + # not the user has an encoding plugin. + + if ($c->can('encoding')) { + $c->{encoding} = ''; + } my ( $title, $error, $infos ); if ( $c->debug ) { @@ -279,11 +294,12 @@ sub finalize_error { - # Trick IE. Old versions of IE would display their own error page instead # of ours if we'd give it less than 512 bytes. $c->res->{body} .= ( ' ' x 512 ); + $c->res->{body} = Encode::encode("UTF-8", $c->res->{body}); + # Return 500 $c->res->status(500); } @@ -716,7 +732,7 @@ not directly available via Catalyst objects $c->request, $c->engine ... BEWARE: If you really need to access some environment variable from your Catalyst application you should use $c->engine->env->{VARNAME} instead of $ENV{VARNAME}, -as in some enviroments the %ENV hash does not contain what you would expect. +as in some environments the %ENV hash does not contain what you would expect. =head1 AUTHORS