From: Wallace Reis Date: Fri, 24 May 2013 00:37:23 +0000 (+0200) Subject: Unicode plugin - rework encoding default config X-Git-Tag: 5.90040~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=1bef5f599dd1a07e3693ea84fe805a31efa08142;hp=1d4df70b12006c9803f80e46d435a1f2610b75f1 Unicode plugin - rework encoding default config The aim is to find a way to: 1) not bust people who are doing the right thing, 2) force people to do the right thing going forward, with new apps, 3) make it easy for people doing the wrong thing to keep doing the wrong thing if they don't or can't fix their apps. Thus, lets basically set "encoding" bit to 'UTF-8' for apps loading the plugin directly (unless provided something else) and remove the default value. --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 0dd64a0..a6170d3 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -2983,9 +2983,13 @@ the plugin name does not begin with C. $plugins = [ grep { m/Unicode::Encoding/ ? do { $class->log->warn( - 'Unicode::Encoding plugin is now part of core,' + 'Unicode::Encoding plugin is auto-applied,' . ' please remove this from your appclass' + . ' and make sure to define "encoding" config' ); + unless (exists $class->config->{'encoding'}) { + $class->config->{'encoding'} = 'UTF-8'; + } () } : $_ } @$plugins ]; diff --git a/lib/Catalyst/Plugin/Unicode/Encoding.pm b/lib/Catalyst/Plugin/Unicode/Encoding.pm index ffcdfae..c1c67d9 100644 --- a/lib/Catalyst/Plugin/Unicode/Encoding.pm +++ b/lib/Catalyst/Plugin/Unicode/Encoding.pm @@ -125,7 +125,7 @@ sub setup { my $conf = $self->config; # Allow an explict undef encoding to disable default of utf-8 - my $enc = exists $conf->{encoding} ? delete $conf->{encoding} : 'UTF-8'; + my $enc = delete $conf->{encoding}; $self->encoding( $enc ); return $self->next::method(@_); diff --git a/t/lib/TestApp.pm b/t/lib/TestApp.pm index e548872..c1ec9b5 100644 --- a/t/lib/TestApp.pm +++ b/t/lib/TestApp.pm @@ -50,6 +50,7 @@ TestApp->config( action_action_nine => { another_extra_arg => 13 } } }, + encoding => 'UTF-8', ); # Test bug found when re-adjusting the metaclass compat code in Moose diff --git a/t/lib/TestApp2.pm b/t/lib/TestApp2.pm index 552b8c6..fcf92bd 100644 --- a/t/lib/TestApp2.pm +++ b/t/lib/TestApp2.pm @@ -5,8 +5,8 @@ use base qw/Catalyst/; use Catalyst qw/Params::Nested/; __PACKAGE__->config( - encoding => $ENV{TESTAPP_ENCODING} -) if $ENV{TESTAPP_ENCODING}; + encoding => 'UTF-8' +); __PACKAGE__->config('name' => 'TestApp2'); diff --git a/t/unicode_plugin_charset_utf8.t b/t/unicode_plugin_charset_utf8.t index 9700b73..81ba9f7 100644 --- a/t/unicode_plugin_charset_utf8.t +++ b/t/unicode_plugin_charset_utf8.t @@ -27,6 +27,6 @@ is scalar(@TestLogger::LOGS), 1 or diag Dumper(\@TestLogger::LOGS); like $TestLogger::LOGS[0], qr/content type is 'iso-8859-1'/; -like $TestLogger::ELOGS[0], qr/plugin is now part of core/; +like $TestLogger::ELOGS[0], qr/Unicode::Encoding plugin/; done_testing;