X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FPlugin%2FUnicode%2FEncoding.pm;h=544d46b591a47577b6dabb1a99067981d6efca8f;hb=8cb32a8d95fb81583243d3f8ba51a9f59d9727b5;hp=63b0c4a519fdb7cb396ef045332d29e55fe29f5c;hpb=abc66d4e4ed40abdfd397dff9722dbce9ca12cba;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Plugin/Unicode/Encoding.pm b/lib/Catalyst/Plugin/Unicode/Encoding.pm index 63b0c4a..544d46b 100644 --- a/lib/Catalyst/Plugin/Unicode/Encoding.pm +++ b/lib/Catalyst/Plugin/Unicode/Encoding.pm @@ -125,10 +125,11 @@ 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(@_); + return $self->next::method(@_) + unless $self->setup_finished; ## hack to stop possibily meaningless test fail... (jnap) } sub _handle_unicode_decoding { @@ -172,7 +173,8 @@ sub _handle_param_unicode_decoding { sub handle_unicode_encoding_exception { my ( $self, $exception_ctx ) = @_; - die $exception_ctx->{error_msg}; + $self->log->warn($exception_ctx->{error_msg}); + return $exception_ctx->{'param_value'}; } 1; @@ -185,97 +187,24 @@ Catalyst::Plugin::Unicode::Encoding - Unicode aware Catalyst =head1 SYNOPSIS - use Catalyst qw[Unicode::Encoding]; + use Catalyst; MyApp->config( encoding => 'UTF-8' ); # A valid Encode encoding =head1 DESCRIPTION -On request, decodes all params from encoding into a sequence of -logical characters. On response, encodes body into encoding. - -=head1 METHODS - -=over 4 - -=item encoding - -Returns an instance of an C encoding - - print $c->encoding->name - -=back - -=head1 OVERLOADED METHODS - -=over - -=item finalize_headers - -Encodes body into encoding. - -=item prepare_uploads - -Decodes parameters, query_parameters, body_parameters and filenames -in file uploads into a sequence of logical characters. - -=item prepare_action - -Decodes request arguments (i.e. C<< $c->request->arguments >>) and -captures (i.e. C<< $c->request->captures >>). - -=item setup - -Setups C<< $c->encoding >> with encoding specified in C<< $c->config->{encoding} >>. - -=item handle_unicode_encoding_exception ($exception_context) - -Method called when decoding process for a request fails. - -An C<$exception_context> hashref is provided to allow you to override the -behaviour of your application when given data with incorrect encodings. - -The default method throws exceptions in the case of invalid request parameters -(resulting in a 500 error), but ignores errors in upload filenames. - -The keys passed in the C<$exception_context> hash are: - -=over - -=item param_value - -The value which was not able to be decoded. - -=item error_msg - -The exception received from L. - -=item encoding_step - -What type of data was being decoded. Valid values are (currently) -C - for request parameters / arguments / captures -and C - for request upload filenames. - -=back - -=back - -=head1 SEE ALSO - -L, L, L, L. +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. =head1 AUTHORS -Christian Hansen, C - -Masahiro Chiba - -Tomas Doran, C +Catalyst Contributors, see Catalyst.pm -=head1 LICENSE +=head1 COPYRIGHT -This library is free software . You can redistribute it and/or modify -it under the same terms as perl itself. +This library is free software. You can redistribute it and/or modify +it under the same terms as Perl itself. =cut