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

Security/EscapeOutputSniff: More modular error codes #2378

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Default $code per request
  • Loading branch information
anomiex committed Sep 5, 2023
commit f5590ce7b2d43fa73a7cfff22f481cace830c204
10 changes: 5 additions & 5 deletions WordPress/Sniffs/Security/EscapeOutputSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public function process_token( $stackPtr ) {
break;
}

return $this->check_code_is_escaped( $start, $end, 'OutputNotEscaped' );
return $this->check_code_is_escaped( $start, $end );
}

/**
Expand Down Expand Up @@ -395,7 +395,7 @@ public function process_matched_token( $stackPtr, $group_name, $matched_content
continue;
}

$this->check_code_is_escaped( $param['start'], ( $param['end'] + 1 ), 'OutputNotEscaped' );
$this->check_code_is_escaped( $param['start'], ( $param['end'] + 1 ) );
}

return $end;
Expand All @@ -414,7 +414,7 @@ public function process_matched_token( $stackPtr, $group_name, $matched_content
return $end;
}

return $this->check_code_is_escaped( $message_param['start'], ( $message_param['end'] + 1 ), 'OutputNotEscaped' );
return $this->check_code_is_escaped( $message_param['start'], ( $message_param['end'] + 1 ) );
}

/*
Expand All @@ -435,7 +435,7 @@ public function process_matched_token( $stackPtr, $group_name, $matched_content

// Examine each parameter individually.
foreach ( $params as $param ) {
$this->check_code_is_escaped( $param['start'], ( $param['end'] + 1 ), 'OutputNotEscaped' );
$this->check_code_is_escaped( $param['start'], ( $param['end'] + 1 ) );
}

return $end;
Expand All @@ -452,7 +452,7 @@ public function process_matched_token( $stackPtr, $group_name, $matched_content
*
* @return int Integer stack pointer to skip forward.
*/
protected function check_code_is_escaped( $start, $end, $code ) {
protected function check_code_is_escaped( $start, $end, $code = 'OutputNotEscaped' ) {
/*
* Check for a ternary operator.
* We only need to do this here if this statement is lacking parenthesis.
Expand Down
Loading