Skip to content

Commit

Permalink
Update sniff to include static method calls
Browse files Browse the repository at this point in the history
Still a WIP
  • Loading branch information
dingo-d committed Aug 28, 2023
1 parent 640d886 commit 5f01f59
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions WordPress/Sniffs/Security/EscapeOutputSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,17 +614,6 @@ protected function check_code_is_escaped( $start, $end ) {
) {
$i = $class_keyword;
continue;
} else { // Static method call. Current token should be flagged and the rest should be skipped.
$content = $this->tokens[ $i ]['content'];

$this->phpcsFile->addError(
"All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '%s'.",
$i,
'OutputNotEscaped',
array( $content )
);

break;
}
}
}
Expand Down Expand Up @@ -748,6 +737,14 @@ protected function check_code_is_escaped( $start, $end ) {

$content = $functionName;

// Check if it's static method call.
$double_colon = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), $end, true );
if ( false !== $double_colon
&& \T_DOUBLE_COLON === $this->tokens[ $double_colon ]['code']
) {
// Set the pointer to the end of the method.
$i = $this->phpcsFile->findNext( \T_CLOSE_PARENTHESIS, $i, $end );
}
} else {
$content = $this->tokens[ $i ]['content'];
$ptr = $i;
Expand Down

0 comments on commit 5f01f59

Please sign in to comment.