X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FPlugin%2FUnicode%2FEncoding.pm;h=ca2dbd5e36e63dd5d1e98e10d5456c4c54f14f4f;hb=dcd79f4c41a518c6bf03f37d2e66f5d5e554a53d;hp=c1c67d9c56b9ae29b03719ab607630992aeab374;hpb=1bef5f599dd1a07e3693ea84fe805a31efa08142;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Plugin/Unicode/Encoding.pm b/lib/Catalyst/Plugin/Unicode/Encoding.pm index c1c67d9..ca2dbd5 100644 --- a/lib/Catalyst/Plugin/Unicode/Encoding.pm +++ b/lib/Catalyst/Plugin/Unicode/Encoding.pm @@ -81,6 +81,7 @@ sub prepare_uploads { $c->next::method(@_); my $enc = $c->encoding; + return unless $enc; for my $key (qw/ parameters query_parameters body_parameters /) { for my $value ( values %{ $c->request->{$key} } ) { @@ -95,15 +96,17 @@ sub prepare_uploads { for my $value ( values %{ $c->request->uploads } ) { # skip if it fails for uploads, as we don't usually want uploads touched # in any way - $_->{filename} = try { - $enc->decode( $_->{filename}, $CHECK ) - } catch { - $c->handle_unicode_encoding_exception({ - param_value => $_->{filename}, - error_msg => $_, - encoding_step => 'uploads', - }); - } for ( ref($value) eq 'ARRAY' ? @{$value} : $value ); + for my $inner_value ( ref($value) eq 'ARRAY' ? @{$value} : $value ) { + $inner_value->{filename} = try { + $enc->decode( $inner_value->{filename}, $CHECK ) + } catch { + $c->handle_unicode_encoding_exception({ + param_value => $inner_value->{filename}, + error_msg => $_, + encoding_step => 'uploads', + }); + }; + } } } @@ -112,6 +115,9 @@ sub prepare_action { my $ret = $c->next::method(@_); + my $enc = $c->encoding; + return $ret unless $enc; + foreach (@{$c->req->arguments}, @{$c->req->captures}) { $_ = $c->_handle_param_unicode_decoding($_); } @@ -128,7 +134,8 @@ sub setup { my $enc = delete $conf->{encoding}; $self->encoding( $enc ); - return $self->next::method(@_); + return $self->next::method(@_) + unless $self->setup_finished; ## hack to stop possibily meaningless test fail... (jnap) } sub _handle_unicode_decoding { @@ -194,7 +201,7 @@ Catalyst::Plugin::Unicode::Encoding - Unicode aware Catalyst This plugin is automatically loaded by apps. Even though is not a core component yet, it will vanish as soon as the code is fully integrated. For more -information, please refer to C section at L. +information, please refer to L. =head1 AUTHORS