You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was investigating an issue in our app until I realized there is a bug in Catalyst itself.
How to reproduce:
have an app read $c->req->body_data—I tried this with a fresh app created by catalyst.pl by just adding that call to the default action method
send invalid JSON like this:
curl -v --json '' http://localhost:3000/
Actual result:
[error] Error Parsing POST 'undef', Error: Can't locate object method "getline" via package "0" (perhaps you forgot to load "0"?) at .../perlbrew/perls/perl-5.38.0-threads-bullseye/lib/site_perl/5.38.0/Catalyst.pm line 4091.
Expected result:
either return (); or a catchable exception from parsing the empty string
I think Pull Request #186 solves part of the problem related with repeated calls on $c->req->body_data but with that the code already fails on $fh->seek (see my comment there). Currently the data handler fails for $fh->getline.
Should the data handler always receive a filehandle, possibly an empty one, or does every data handler need to check whether a filehandle is present first?
The text was updated successfully, but these errors were encountered:
dboehmer
changed the title
$c->req->body_data dies internally if run twice with invalid JSON request data
$c->req->body_data dies internally for JSON request with empty HTTP message body
Oct 24, 2024
I was investigating an issue in our app until I realized there is a bug in Catalyst itself.
How to reproduce:
$c->req->body_data
—I tried this with a fresh app created bycatalyst.pl
by just adding that call to the default action methodcurl -v --json '' http://localhost:3000/
Actual result:
Expected result:
return ();
or a catchable exception from parsing the empty stringI think Pull Request #186 solves part of the problem related with repeated calls on
$c->req->body_data
but with that the code already fails on$fh->seek
(see my comment there). Currently the data handler fails for$fh->getline
.Should the data handler always receive a filehandle, possibly an empty one, or does every data handler need to check whether a filehandle is present first?
The text was updated successfully, but these errors were encountered: