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',
+ });
+ };
+ }
}
}
my $escape_str = uri_escape_utf8($decode_str);
check_parameter(GET "/?myparam=$escape_str");
+check_parameter(POST '/',
+ Content_Type => 'form-data',
+ Content => [
+ 'myparam' => [
+ "$Bin/unicode_plugin_no_encoding.t",
+ "$Bin/unicode_plugin_request_decode.t",
+ ]
+ ],
+);
sub check_parameter {
my ( undef, $c ) = ctx_request(shift);
- is $c->res->output => $encode_str;
my $myparam = $c->req->param('myparam');
ok !utf8::is_utf8($myparam);
- is $myparam => $encode_str;
+ unless ( $c->request->method eq 'POST' ) {
+ is $c->res->output => $encode_str;
+ is $myparam => $encode_str;
+ }
is scalar(@TestLogger::ELOGS), 2
or diag Dumper(\@TestLogger::ELOGS);