Scrub body_data / data params too (e.g. POSTed JSON) #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If we have
$c->req->body_data- for e.g. the request was a POST with a JSON body which Catalyst has decoded into$c->req->body_data- then scrub HTML in there too (but applying the sameignore_paramschecks so that you can exempt certain JSON body params from scrubbing).Also, if we have
$c->req->dataadded by the role Catalyst::TraitFor::Request::REST which Catalyst::Action::REST / Catalyst::Controller::REST apply to Catalyst::Request to provide RESTful API tools, we need to scrub that too.Also moved the
ignore_paramstests intot/03_params.t, and added the tests for this new feature there too - don't need so many individual test apps, when most features can be tested with a single test app.A new test script and associated test app was added for the tests for scrubbing
$c->req->datathough, as they depend onCatalyst::Controller::RESTbeing available.There is a slightly ugly bit of monkey-patching to handle an issue that causes JSON parsing via the default handler for
application/jsonto fail if the body content filehandle has already been read - that's the fix I submitted in PR perl-catalyst/catalyst-runtime/pull/186 but fixed via monkey-patching in the meantime.