Subject: | nonworking if ShiftJIS charaset specified |
Hi.
I found a bug.
In case non upper case charset specified in $c->res->content_type,
error occrued.
Please check this code!! Thanks.
Index: lib/Catalyst/Plugin/Unicode/Encoding.pm
===================================================================
--- lib/Catalyst/Plugin/Unicode/Encoding.pm (revision 14051)
+++ lib/Catalyst/Plugin/Unicode/Encoding.pm (working copy)
@@ -55,7 +55,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 ");
Subject: | encoding_diff.txt |
Index: t/04live.t
===================================================================
--- t/04live.t (revision 14051)
+++ t/04live.t (working copy)
@@ -81,5 +81,16 @@
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;
Index: t/lib/TestApp/Controller/Root.pm
===================================================================
--- t/lib/TestApp/Controller/Root.pm (revision 14051)
+++ t/lib/TestApp/Controller/Root.pm (working copy)
@@ -45,6 +45,14 @@
$c->response->body('LATIN SMALL LETTER E WITH ACUTE: é');
}
+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");
+}
+
sub file :Local {
my ($self, $c) = @_;
close *STDERR; # i am evil.
Index: lib/Catalyst/Plugin/Unicode/Encoding.pm
===================================================================
--- lib/Catalyst/Plugin/Unicode/Encoding.pm (revision 14051)
+++ lib/Catalyst/Plugin/Unicode/Encoding.pm (working copy)
@@ -55,7 +55,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 ");