Revert "Unicode plugin - rework exception handler"
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Plugin / Unicode / Encoding.pm
index c1c67d9..2f2e8d5 100644 (file)
@@ -95,15 +95,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',
+                });
+            };
+        }
     }
 }
 
@@ -128,7 +130,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 {