[Catalyst-commits] r14099 - in
Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback:
. lib/Catalyst/Plugin/Unicode t t/lib
wreis at dev.catalyst.perl.org
wreis at dev.catalyst.perl.org
Tue Sep 20 20:00:19 GMT 2011
Author: wreis
Date: 2011-09-20 20:00:18 +0000 (Tue, 20 Sep 2011)
New Revision: 14099
Modified:
Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/Changes
Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/lib/Catalyst/Plugin/Unicode/Encoding.pm
Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/t/06request_decode.t
Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/t/lib/TestApp.pm
Log:
Split the params/args/captures handlers for failed decoding process
Modified: Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/Changes
===================================================================
--- Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/Changes 2011-09-07 20:21:24 UTC (rev 14098)
+++ Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/Changes 2011-09-20 20:00:18 UTC (rev 14099)
@@ -1,8 +1,11 @@
Revision history for Perl extension Catalyst::Plugin::Unicode::Encoding
-1.2
+1.3
+ - Split the params/args/captures handlers for failed decoding process
+
+1.2 2011-09-07 21:19:00
- Use a callback in failed decoding process so that the app has a chance
- to handle it nicely
+ to handle it nicely
1.1 2010-07-05 17:52:00
- Skip Mech tests unless TWMC is a high enough version. (RT#55302)
Modified: Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/lib/Catalyst/Plugin/Unicode/Encoding.pm
===================================================================
--- Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/lib/Catalyst/Plugin/Unicode/Encoding.pm 2011-09-07 20:21:24 UTC (rev 14098)
+++ Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/lib/Catalyst/Plugin/Unicode/Encoding.pm 2011-09-20 20:00:18 UTC (rev 14099)
@@ -81,9 +81,10 @@
$c->next::method(@_);
my $enc = $c->encoding;
+ my $req = $c->request;
for my $key (qw/ parameters query_parameters body_parameters /) {
- for my $value ( values %{ $c->request->{$key} } ) {
+ for my $value ( values %{ $req->{$key} } ) {
# TODO: Hash support from the Params::Nested
if ( ref $value && ref $value ne 'ARRAY' ) {
@@ -95,11 +96,11 @@
# this avoids exception if we have already decoded content, and is _not_ the
# same as not encoding on output which is bad news (as it does the wrong thing
# for latin1 chars for example)..
- $_ = $c->_handle_param_unicode_decoding($_);
+ $_ = $c->_handle_param_unicode_decoding($_, 'params');
}
}
}
- for my $value ( values %{ $c->request->uploads } ) {
+ for my $value ( values %{ $req->uploads } ) {
# skip if it fails for uploads, as we don't usually want uploads touched
# in any way
$_->{filename} = try {
@@ -120,7 +121,7 @@
my $ret = $c->next::method(@_);
foreach (@{$c->req->arguments}, @{$c->req->captures}) {
- $_ = $c->_handle_param_unicode_decoding($_);
+ $_ = $c->_handle_param_unicode_decoding($_, 'args');
}
return $ret;
@@ -139,7 +140,7 @@
}
sub _handle_param_unicode_decoding {
- my ( $self, $value ) = @_;
+ my ( $self, $value, $step ) = @_;
my $enc = $self->encoding;
return try {
Encode::is_utf8( $value ) ?
@@ -150,7 +151,7 @@
$self->handle_unicode_encoding_exception({
param_value => $value,
error_msg => $_,
- encoding_step => 'params',
+ encoding_step => $step,
});
};
}
@@ -239,7 +240,7 @@
=item encoding_step
What type of data was being decoded. Valid values are (currently)
-C<params> - for request parameters / arguments / captures
+C<params> - for request parameters; C<args> for path arguments / captures;
and C<uploads> - for request upload filenames.
=back
Modified: Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/t/06request_decode.t
===================================================================
--- Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/t/06request_decode.t 2011-09-07 20:21:24 UTC (rev 14098)
+++ Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/t/06request_decode.t 2011-09-20 20:00:18 UTC (rev 14099)
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 5 * 5;
+use Test::More tests => 6 * 4;
use utf8;
# setup library path
@@ -39,7 +39,6 @@
check_fallback(GET "/?q=${non_utf8_data}");
check_fallback(GET "/${non_utf8_data}");
check_fallback(GET "/capture/${non_utf8_data}");
-check_fallback(POST '/', ['foo' => $non_utf8_data]);
sub check_parameter {
my ( undef, $c ) = ctx_request(shift);
Modified: Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/t/lib/TestApp.pm
===================================================================
--- Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/t/lib/TestApp.pm 2011-09-07 20:21:24 UTC (rev 14098)
+++ Catalyst-Plugin-Unicode-Encoding/branches/decoding_callback/t/lib/TestApp.pm 2011-09-20 20:00:18 UTC (rev 14099)
@@ -13,8 +13,8 @@
__PACKAGE__->setup;
sub handle_unicode_encoding_exception {
- my ( $self, $param_value, $error_msg ) = @_;
- return $param_value;
+ my ( $self, $exception_ctx ) = @_;
+ return $exception_ctx->{'param_value'};
}
1;
More information about the Catalyst-commits
mailing list