make the new encoding stuff work with ash multivalue if you want that stuff
[catagits/Catalyst-Runtime.git] / lib / Catalyst.pm
index 7c20e93..725494c 100644 (file)
@@ -2280,23 +2280,6 @@ Prepares body parameters.
 sub prepare_body_parameters {
     my $c = shift;
     $c->request->prepare_body_parameters( $c, @_ );
-
-    # If we have an encoding configured (like UTF-8) in general we expect a client
-    # to POST with the encoding we fufilled the request in. Otherwise don't do any
-    # encoding (good change wide chars could be in HTML entity style llike the old
-    # days -JNAP
-
-    # so, now that HTTP::Body prepared the body params, we gotta 'walk' the structure
-    # and do any needed decoding.
-
-    # This only does something if the encoding is set via the encoding param.  Remember
-    # this is assuming the client is not bad and responds with what you provided.  In
-    # general you can just use utf8 and get away with it.
-
-    if($c->encoding) {
-        my $current_parameters = $c->request->body_parameters;
-        $c->request->body_parameters($c->_handle_unicode_decoding($current_parameters));
-    }
 }
 
 =head2 $c->prepare_connection
@@ -2579,26 +2562,6 @@ Prepares uploads.
 sub prepare_uploads {
     my $c = shift;
     $c->engine->prepare_uploads( $c, @_ );
-
-    my $enc = $c->encoding;
-    return unless $enc;
-
-    ## Only trying to decode the filenames.
-    for my $value ( values %{ $c->request->uploads } ) {
-        # skip if it fails for uploads, as we don't usually want uploads touched
-        # in any way
-        for my $inner_value ( ref($value) eq 'ARRAY' ? @{$value} : $value ) {
-            $inner_value->{filename} = try {
-                $enc->decode( $inner_value->{filename}, $c->_encode_check )
-            } catch {
-                $c->handle_unicode_encoding_exception({
-                    param_value => $inner_value->{filename},
-                    error_msg => $_,
-                    encoding_step => 'uploads',
-                });
-            };
-        }
-    }
 }
 
 =head2 $c->prepare_write
@@ -3082,6 +3045,7 @@ Sets up the input/output encoding.  See L<ENCODING>
 
 sub setup_encoding {
     my $c = shift;
+    # This is where you'd set a default encoding
     my $enc = delete $c->config->{encoding};
     $c->encoding( $enc ) if defined $enc;
 }
@@ -3124,7 +3088,10 @@ sub _handle_unicode_decoding {
         foreach (keys %$value) {
             my $encoded_key = $self->_handle_param_unicode_decoding($_);
             $value->{$encoded_key} = $self->_handle_unicode_decoding($value->{$_});
-            delete $value->{$_};
+
+            # If the key was encoded we now have two (the original and current so
+            # delete the original.
+            delete $value->{$_} if $_ ne $encoded_key;
         }
         return $value;
     }