[Catalyst-commits] r14328 - in
Catalyst-Plugin-Unicode-Encoding/trunk: .
lib/Catalyst/Plugin/Unicode t t/lib/TestApp/Controller
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Wed Jul 18 19:27:55 GMT 2012
Author: t0m
Date: 2012-07-18 19:27:55 +0000 (Wed, 18 Jul 2012)
New Revision: 14328
Modified:
Catalyst-Plugin-Unicode-Encoding/trunk/Changes
Catalyst-Plugin-Unicode-Encoding/trunk/lib/Catalyst/Plugin/Unicode/Encoding.pm
Catalyst-Plugin-Unicode-Encoding/trunk/t/04live.t
Catalyst-Plugin-Unicode-Encoding/trunk/t/lib/TestApp/Controller/Root.pm
Log:
Shift_JIS fixes. RT#69677
Modified: Catalyst-Plugin-Unicode-Encoding/trunk/Changes
===================================================================
--- Catalyst-Plugin-Unicode-Encoding/trunk/Changes 2012-07-15 20:06:51 UTC (rev 14327)
+++ Catalyst-Plugin-Unicode-Encoding/trunk/Changes 2012-07-18 19:27:55 UTC (rev 14328)
@@ -1,5 +1,8 @@
Revision history for Perl extension Catalyst::Plugin::Unicode::Encoding
+ - Work correcly with Shift_JIS and other encodings whos names are not
+ upper case. RT#69677
+
1.7 2012-05-09 22:13:00
- Add proper tests for charset parsing issues.
- Fix all known charset parsing issues.
Modified: Catalyst-Plugin-Unicode-Encoding/trunk/lib/Catalyst/Plugin/Unicode/Encoding.pm
===================================================================
--- Catalyst-Plugin-Unicode-Encoding/trunk/lib/Catalyst/Plugin/Unicode/Encoding.pm 2012-07-15 20:06:51 UTC (rev 14327)
+++ Catalyst-Plugin-Unicode-Encoding/trunk/lib/Catalyst/Plugin/Unicode/Encoding.pm 2012-07-18 19:27:55 UTC (rev 14328)
@@ -57,7 +57,7 @@
unless $c->response->content_type =~ /^text|xml$|javascript$/;
if ($ct_enc && $ct_enc =~ /charset=([^;]*)/) {
- if (uc($1) ne $enc->mime_name) {
+ if (uc($1) ne uc($enc->mime_name)) {
$c->log->debug("Unicode::Encoding is set to encode in '" .
$enc->mime_name .
"', content type is '$1', not encoding ");
Modified: Catalyst-Plugin-Unicode-Encoding/trunk/t/04live.t
===================================================================
--- Catalyst-Plugin-Unicode-Encoding/trunk/t/04live.t 2012-07-15 20:06:51 UTC (rev 14327)
+++ Catalyst-Plugin-Unicode-Encoding/trunk/t/04live.t 2012-07-18 19:27:55 UTC (rev 14328)
@@ -81,5 +81,13 @@
is ($got, $exp, 'content octets are UTF-8');
}
+{
+ $mech->get_ok('http://localhost/shift_jis', 'get shift_jis');
+ is ($mech->response->header('Content-Type'), 'text/plain; charset=Shift_JIS', 'Content-Type with charset');
+ my $exp = "\xE3\x81\xBB\xE3\x81\x92";
+ my $got = Encode::encode_utf8($mech->content);
+ is ($got, $exp, 'content octets are Shift_JIS');
+}
+
done_testing;
Modified: Catalyst-Plugin-Unicode-Encoding/trunk/t/lib/TestApp/Controller/Root.pm
===================================================================
--- Catalyst-Plugin-Unicode-Encoding/trunk/t/lib/TestApp/Controller/Root.pm 2012-07-15 20:06:51 UTC (rev 14327)
+++ Catalyst-Plugin-Unicode-Encoding/trunk/t/lib/TestApp/Controller/Root.pm 2012-07-18 19:27:55 UTC (rev 14328)
@@ -68,4 +68,13 @@
$c->forward('main');
}
+sub shift_jis :Local {
+ my ($self, $c) = @_;
+ my $data = "ほげ"; # hoge!
+ $c->response->body($data); # should be decoded
+ $c->res->content_type('text/plain; charset=Shift_JIS');
+ $c->encoding("Shift_JIS");
+}
+
1;
+
More information about the Catalyst-commits
mailing list