From: Andrew Rodland Date: Fri, 9 Jul 2010 09:40:44 +0000 (+0000) Subject: Try harder to make finalize_error encoding-safe. X-Git-Tag: 5.80025~2^2~4^2~1^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=361ba9b28e3d6fe8a80440e8a38ed9b05b72933d Try harder to make finalize_error encoding-safe. --- diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 509585f..e770f32 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -10,6 +10,8 @@ use HTML::Entities; use HTTP::Body; use HTTP::Headers; use URI::QueryParam; +use Encode (); +use utf8; use namespace::clean -except => 'meta'; @@ -131,6 +133,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 +289,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); }