Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EscapeOutput: defensive coding #1939

Merged
merged 1 commit into from
Jul 22, 2020

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jul 22, 2020

The PassedParameters::getParameter() method (and the Sniff::get_function_call_parameter() method before it), either returns an array with information on the parameter or false if the parameter does not exist.

A call to trigger_error() and the likes, without passing parameters is a little useless and will throw a warning in PHP 4/5/7 and a fatal ArgumentCountError in PHP 8.

However, those types of errors are not the concern of this sniff, so if a call to these functions is encountered without arguments, the sniff should conclude that there is nothing which needs escaping and bow out.

Fix now, including unit test to safeguard against it in the future.

The `PassedParameters::getParameter()` method (and the `Sniff::get_function_call_parameter()` method before it), either returns an array with information on the parameter or `false` if the parameter does not exist.

A call to `trigger_error()` and the likes, without passing parameters is a little useless and will throw a warning in PHP 4/5/7 and a fatal `ArgumentCountError` in PHP 8.

However, those types of errors are not the concern of this sniff, so if a call to these functions is encountered without arguments, the sniff should conclude that there is nothing which needs escaping and bow out.

Fix now, including unit tests to safeguard against it in the future.
@GaryJones GaryJones merged commit 2f09835 into develop Jul 22, 2020
@GaryJones GaryJones deleted the feature/escapeoutput-defensive-coding branch July 22, 2020 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants