Require unlashing of input superglobals #395
Merged
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.
This updates the validated/sanitized input sniff to also check for
slashing. This could have been made into another sniff instead,
however, it would have required lots of duplicated logic and this sniff
would need to be updated to accommodate the use of
wp_unslash()
anyway.
Currently only
wp_unslash()
is recognized as an unlashing function,but this can be changed in the future if needed.
The sniff currently requires that
wp_unslash()
be used before thedata is passed through a sanitizing function. Sanitizing first and then
wrapping that in
wp_unslash()
is not accepted.The error for missing the use of
wp_unslash()
is independent of themissing sanitizing function error, so an error will be given for
missing use of an unslashing function whether or not a sanitizing
function is used, and vice versa.
Unslashing is not required when sanitization is provided via casting,
or when certain sanitization functions are used which implicitly or
explicitly perform an unslash or for which unslashing isn’t necessary.
absint()
implicitly unslashes, andsanitize_key()
will removeslashes explicitly. And unslashing isn’t necessary when testing a value
with
is_array()
. This list can be expanded in the future, and isconfigurable via the
customUnslashingSanitizingFunctions
property.See #172