-
Notifications
You must be signed in to change notification settings - Fork 40
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
ProperEscapingFunction: flag printf() usages for placeholders being escaped incorrectly #674
Comments
Notes for implementation:
|
That is irrelevant for this sniff, or at least, the other checks in the sniff don't take it into account. The below code will be flagged by the sniff, even though it is not being send to output. $text = '<div class="' . esc_html( $class ) . '">'; |
Hmmm, do you think we should change the sniff to only account for |
No, I don't. The standard uses the WPCS This sniff is a check that when escaping functions are used, the correct one is used for each context. In other words, as things are, these two sniffs are complimentary and will enhance each other. If this sniff was limited to output context only, it would no longer be complimentary, but would become a subset of the WPCS sniff and should be merged into it. |
Fair point. I've edited the |
Describe the solution you'd like
When
printf()
is used, we should ensure that the content in the placeholders are correctly escaped.What code should be reported as a violation?
What code should not be reported as a violation?
Correct usages of escaping:
Correct usages of escaping with translation functions:
Additional context
The text was updated successfully, but these errors were encountered: