[Catalyst-commits] r13407 - Catalyst-Runtime/5.80/trunk/lib/Catalyst

hobbs at dev.catalyst.perl.org hobbs at dev.catalyst.perl.org
Fri Jul 9 09:40:44 GMT 2010


Author: hobbs
Date: 2010-07-09 10:40:44 +0100 (Fri, 09 Jul 2010)
New Revision: 13407

Modified:
   Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine.pm
Log:
Try harder to make finalize_error encoding-safe.


Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine.pm	2010-07-09 00:25:31 UTC (rev 13406)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine.pm	2010-07-09 09:40:44 UTC (rev 13407)
@@ -10,6 +10,8 @@
 use HTTP::Body;
 use HTTP::Headers;
 use URI::QueryParam;
+use Encode ();
+use utf8;
 
 use namespace::clean -except => 'meta';
 
@@ -131,7 +133,15 @@
 
     $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 @@
 </body>
 </html>
 
-
     # 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);
 }




More information about the Catalyst-commits mailing list