X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FRequest.pm;h=671dd51e4368360260818c7a7add45624329ef27;hp=f5232b91ed3fcc60f3dba0a3705082c14504821d;hb=b94f8e72c1c8e8348efc0eb96660dd977a838ea7;hpb=0810283f5e3c710d09ab56ceb8fb0b6bfbe3bbe9 diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index f5232b9..671dd51 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -10,7 +10,7 @@ use HTTP::Headers; use Stream::Buffered; use Hash::MultiValue; use Scalar::Util; - +use Catalyst::Exception; use Moose; use namespace::clean -except => 'meta'; @@ -118,7 +118,11 @@ has body_data => ( sub _build_body_data { my ($self) = @_; - my $content_type = $self->content_type; + + # Not sure if these returns should not be exceptions... + my $content_type = $self->content_type || return; + return unless ($self->method eq 'POST' || $self->method eq 'PUT'); + my ($match) = grep { $content_type =~/$_/i } keys(%{$self->data_handlers}); @@ -127,7 +131,7 @@ sub _build_body_data { local $_ = $fh; return $self->data_handlers->{$match}->($fh, $self); } else { - return undef; + Catalyst::Exception->throw("$content_type is does not have an available data handler"); } } @@ -502,6 +506,13 @@ data of the type 'application/json' and return access to that data via this method. You may define addition data_handlers via a global configuration setting. See L for more information. +If the POST is malformed in some way (such as undefined or not content that +matches the content-type) we raise a L with the error +text as the message. + +If the POSTed content type does not match an availabled data handler, this +will also raise an exception. + =head2 $req->body_parameters Returns a reference to a hash containing body (POST) parameters. Values can @@ -636,8 +647,10 @@ If multiple C parameters are provided this code might corrupt data or cause a hash initialization error. For a more straightforward interface see C<< $c->req->parameters >>. -B A recently discovered exploit in L style param methods does exist -in L. Here's the whitepaper of the exploit: +B Interfaces like this, which are based on L and the C method +are now known to cause demonstrated exploits. It is highly recommended that you +avoid using this method, and migrate existing code away from it. Here's the +whitepaper of the exploit: L @@ -681,6 +694,9 @@ keyword: foo => scalar($c->req->param('foo')), }); +Upcoming versions of L will disable this interface by default and require +you to positively enable it should you require it for backwards compatibility reasons. + =cut sub param {