X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=ea85e2881e683f617b55bcb4d9172cecbb1c2a1f;hb=71ac9a50d280950385f9cb9d1a5ba72dd536b8e6;hp=8480b7186b0d9ec66a17be19e83e9cad8af17ffb;hpb=324b08a421e5a48a0948bada9b582b7b03be42b5;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 8480b71..ea85e28 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -76,7 +76,7 @@ sub finalize_body { if($res->_has_response_cb) { ## we have not called the response callback yet, so we are safe to send ## the whole body to PSGI - + my @headers; $res->headers->scan(sub { push @headers, @_ }); @@ -92,12 +92,12 @@ sub finalize_body { # In the past, Catalyst only looked for ->read not ->getline. It is very possible # that one might have an object that respected read but did not have getline. # As a result, we need to handle this case for backcompat. - + # We will just do the old loop for now. In a future version of Catalyst this support - # will be removed and one will have to rewrite their custom object or use + # will be removed and one will have to rewrite their custom object or use # Plack::Middleware::AdaptFilehandleRead. In anycase support for this is officially # deprecated and described as such as of 5.90060 - + my $got; do { $got = read $body, my ($buffer), $CHUNKSIZE; @@ -109,7 +109,7 @@ sub finalize_body { } else { # Looks like for backcompat reasons we need to be able to deal # with stringyfiable objects. - $body = ["$body"]; + $body = ["$body"]; } } elsif(ref $body) { if( (ref($body) eq 'GLOB') or (ref($body) eq 'ARRAY')) { @@ -139,7 +139,7 @@ sub finalize_body { ## for backcompat we still need to handle a ->body. I guess I could see ## someone calling ->write to presend some stuff, and then doing the rest ## via ->body, like in a template. - + ## We'll just use the old, existing code for this (or most of it) if(my $body = $res->body) { @@ -158,7 +158,7 @@ sub finalize_body { close $body; } else { - + # Case where body was set after calling ->write. We'd prefer not to # support this, but I can see some use cases with the way most of the # views work. Since body has already been encoded, we need to do @@ -249,7 +249,7 @@ sub finalize_error { $c->res->content_type('text/html; charset=utf-8'); my $name = ref($c)->config->{name} || join(' ', split('::', ref $c)); - + # Prevent Catalyst::Plugin::Unicode::Encoding from running. # This is a little nasty, but it's the best way to be clean whether or # not the user has an encoding plugin. @@ -574,15 +574,18 @@ sub prepare_query_parameters { my ($self, $c) = @_; my $env = $c->request->env; my $do_not_decode_query = $c->config->{do_not_decode_query}; - my $default_query_encoding = $c->config->{default_query_encoding} || - ($c->config->{decode_query_using_global_encoding} ? - $c->encoding : 'UTF-8'); + my $old_encoding; + if(my $new = $c->config->{default_query_encoding}) { + $old_encoding = $c->encoding; + $c->encoding($new); + } + + my $check = $c->config->{do_not_check_query_encoding} ? undef :$c->_encode_check; my $decoder = sub { my $str = shift; return $str if $do_not_decode_query; - return $str unless $default_query_encoding; - return decode( $default_query_encoding, $str); + return $c->_handle_param_unicode_decoding($str, $check); }; my $query_string = exists $env->{QUERY_STRING} @@ -612,6 +615,7 @@ sub prepare_query_parameters { } + $c->encoding($old_encoding) if $old_encoding; $c->request->query_parameters( $c->request->_use_hash_multivalue ? $p : $p->mixed ); }