[Catalyst-commits] r11762 - in
Catalyst-Plugin-Unicode-Encoding/branches/support_upload_filename:
lib/Catalyst/Plugin/Unicode t t/lib
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Thu Nov 5 01:39:56 GMT 2009
Author: t0m
Date: 2009-11-05 01:39:56 +0000 (Thu, 05 Nov 2009)
New Revision: 11762
Modified:
Catalyst-Plugin-Unicode-Encoding/branches/support_upload_filename/lib/Catalyst/Plugin/Unicode/Encoding.pm
Catalyst-Plugin-Unicode-Encoding/branches/support_upload_filename/t/06request_decode.t
Catalyst-Plugin-Unicode-Encoding/branches/support_upload_filename/t/lib/TestApp.pm
Log:
More tests
Modified: Catalyst-Plugin-Unicode-Encoding/branches/support_upload_filename/lib/Catalyst/Plugin/Unicode/Encoding.pm
===================================================================
--- Catalyst-Plugin-Unicode-Encoding/branches/support_upload_filename/lib/Catalyst/Plugin/Unicode/Encoding.pm 2009-11-05 00:11:15 UTC (rev 11761)
+++ Catalyst-Plugin-Unicode-Encoding/branches/support_upload_filename/lib/Catalyst/Plugin/Unicode/Encoding.pm 2009-11-05 01:39:56 UTC (rev 11762)
@@ -72,6 +72,7 @@
$c->next::method(@_);
}
+# Note we have to hook here as uploads also add to the request parameters
sub prepare_uploads {
my $c = shift;
@@ -79,15 +80,20 @@
my $enc = $c->encoding;
- for my $value ( values %{ $c->request->{parameters} } ) {
+ for my $key (qw/ parameters query_parameters body_parameters /) {
+ for my $value ( values %{ $c->request->{$key} } ) {
- # TODO: Hash support from the Params::Nested
- if ( ref $value && ref $value ne 'ARRAY' ) {
- next;
+ # TODO: Hash support from the Params::Nested
+ if ( ref $value && ref $value ne 'ARRAY' ) {
+ next;
+ }
+
+ $_ = $enc->decode( $_, $CHECK ) for ( ref($value) ? @{$value} : $value );
}
-
- $_ = $enc->decode( $_, $CHECK ) for ( ref($value) ? @{$value} : $value );
}
+ for my $value ( values %{ $c->request->uploads } ) {
+ $_->{filename} = $enc->decode( $_->{filename}, $CHECK ) for ( ref($value) eq 'ARRAY' ? @{$value} : $value );
+ }
}
sub setup {
Modified: Catalyst-Plugin-Unicode-Encoding/branches/support_upload_filename/t/06request_decode.t
===================================================================
--- Catalyst-Plugin-Unicode-Encoding/branches/support_upload_filename/t/06request_decode.t 2009-11-05 00:11:15 UTC (rev 11761)
+++ Catalyst-Plugin-Unicode-Encoding/branches/support_upload_filename/t/06request_decode.t 2009-11-05 01:39:56 UTC (rev 11762)
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 3 * 3;
+use Test::More tests => 5 * 3;
use utf8;
# setup library path
@@ -38,6 +38,12 @@
my $foo = $c->req->param('foo');
ok utf8::is_utf8($foo);
is $foo => $decode_str;
+
+ my $other_foo = $c->req->method eq 'POST'
+ ? $c->req->upload('foo')
+ ? $c->req->upload('foo')->filename
+ : $c->req->body_parameters->{foo}
+ : $c->req->query_parameters->{foo};
+ ok utf8::is_utf8($other_foo);
+ is $other_foo => $decode_str;
}
-
-
Modified: Catalyst-Plugin-Unicode-Encoding/branches/support_upload_filename/t/lib/TestApp.pm
===================================================================
--- Catalyst-Plugin-Unicode-Encoding/branches/support_upload_filename/t/lib/TestApp.pm 2009-11-05 00:11:15 UTC (rev 11761)
+++ Catalyst-Plugin-Unicode-Encoding/branches/support_upload_filename/t/lib/TestApp.pm 2009-11-05 01:39:56 UTC (rev 11762)
@@ -1,13 +1,15 @@
package TestApp;
use strict;
use warnings;
-
+use base qw/Catalyst/;
use Catalyst qw/Unicode::Encoding/;
__PACKAGE__->config(
encoding => $ENV{TESTAPP_ENCODING}
) if $ENV{TESTAPP_ENCODING};
+__PACKAGE__->config('name' => 'TestApp');
+
__PACKAGE__->setup;
1;
More information about the Catalyst-commits
mailing list