Skip to content

Commit

Permalink
Fix one error missing identifier.
Browse files Browse the repository at this point in the history
Also unduplicated error data in same sniff.
  • Loading branch information
jrfnl authored and grappler committed Sep 25, 2016
1 parent 353bfde commit d56dd27
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions WordPress/Sniffs/VIP/ValidatedSanitizedInputSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
$this->get_interpolated_variables( $tokens[ $stackPtr ]['content'] )
);
foreach ( array_intersect( $interpolated_variables, $superglobals ) as $bad_variable ) {
$phpcsFile->addError( 'Detected usage of a non-sanitized, non-validated input variable %s: %s', $stackPtr, null, array( $bad_variable, $tokens[ $stackPtr ]['content'] ) );
$phpcsFile->addError( 'Detected usage of a non-sanitized, non-validated input variable %s: %s', $stackPtr, 'InputNotValidatedNotSanitized', array( $bad_variable, $tokens[ $stackPtr ]['content'] ) );
}

return;
Expand All @@ -129,9 +129,11 @@ public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
return;
}

$error_data = array( $tokens[ $stackPtr ]['content'] );

// Check for validation first.
if ( ! $this->is_validated( $stackPtr, $array_key, $this->check_validation_in_scope_only ) ) {
$phpcsFile->addError( 'Detected usage of a non-validated input variable: %s', $stackPtr, 'InputNotValidated', array( $tokens[ $stackPtr ]['content'] ) );
$phpcsFile->addError( 'Detected usage of a non-validated input variable: %s', $stackPtr, 'InputNotValidated', $error_data );
// return; // Should we just return and not look for sanitizing functions ?
}

Expand All @@ -146,7 +148,7 @@ public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {

// Now look for sanitizing functions.
if ( ! $this->is_sanitized( $stackPtr, true ) ) {
$phpcsFile->addError( 'Detected usage of a non-sanitized input variable: %s', $stackPtr, 'InputNotSanitized', array( $tokens[ $stackPtr ]['content'] ) );
$phpcsFile->addError( 'Detected usage of a non-sanitized input variable: %s', $stackPtr, 'InputNotSanitized', $error_data );
}

return;
Expand Down

0 comments on commit d56dd27

Please sign in to comment.