ProperEscapingFunction: fix overreach#668
Merged
rebeccahum merged 1 commit intodevelopfrom Apr 21, 2021
Merged
Conversation
As part of the changes made in 624, the `T_COMMA` token was added to the list of tokens to skip over to allow for `echo` statements with multiple arguments passed as a coma-delimited list. As a side-effect, this caused the sniff to also examine `[s]printf()`-like function calls where the first parameter is a text string, while the second is often a variable within a call to one of the escaping functions. The current change fixes this by only adding the `T_COMMA` token to the "ignore when looking for the previous token"-list when in an `echo` statement. Includes unit test. Fixes 667 Additional notes: * I've run the sniff over WP Core to verify the fix and have verified that all 23 violations being throw up are correctly detected violations. * If it would be considered a good idea to also examine, `[s]printf()`-like function calls for this sniff for proper escaping, I suggest opening a separate, new feature request as that change would need significantly different and quite complex logic and does not fall within the scope of this bug fix.
Closed
2 tasks
|
It works much better but there are still false positives involving See annotations in PR. |
|
Sorry, I was mistaken. Our code was using |
Collaborator
Author
|
Thanks for testing @westonruter and glad to hear that this PR fixes the issue. |
rebeccahum
approved these changes
Apr 21, 2021
Contributor
rebeccahum
left a comment
There was a problem hiding this comment.
Tested and works great!
|
Hello, |
Contributor
|
@manooweb Hi! This will be released with 2.3.1, which we are hoping to within the next few days. |
|
Ok 👍 thanks |
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
As part of the changes made in #624, the
T_COMMAtoken was added to the list of tokens to skip over, to allow forechostatements with multiple arguments passed as a coma-delimited list.As a side-effect, this caused the sniff to also examine
[s]printf()-like function calls where the first parameter is a text string, while the second is often a variable within a call to one of the escaping functions.The current change fixes this by only adding the
T_COMMAtoken to the "ignore when looking for the previous token"-list when in anechostatement.Includes unit test.
Fixes #667
Additional notes:
[s]printf()-like function calls for this sniff for proper escaping, I suggest opening a separate, new feature request as that change would need significantly different and quite complex logic and does not fall within the scope of this bug fix.