From e6fd7607d71808975388a67bddd491ff7120682f Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Sun, 15 May 2011 14:32:49 +0000 Subject: [PATCH] Add check for evil, EVIL @ --- maintenance/checkSyntax.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/maintenance/checkSyntax.php b/maintenance/checkSyntax.php index bcde6a211c..ad52a18a42 100644 --- a/maintenance/checkSyntax.php +++ b/maintenance/checkSyntax.php @@ -275,7 +275,9 @@ class CheckSyntax extends Maintenance { } $text = file_get_contents( $file ); + $tokens = token_get_all( $text ); + $this->checkEvilToken( $file, $tokens, '@', 'Error supression operator (@)'); $this->checkRegex( $file, $text, '/^[\s\r\n]+<\?/', 'leading whitespace' ); $this->checkRegex( $file, $text, '/\?>[\s\r\n]*$/', 'trailing ?>' ); $this->checkRegex( $file, $text, '/^[\xFF\xFE\xEF]/', 'byte-order mark' ); @@ -292,6 +294,18 @@ class CheckSyntax extends Maintenance { $this->mWarnings[$file][] = $desc; $this->output( "Warning in file $file: $desc found.\n" ); } + + private function checkEvilToken( $file, $tokens, $evilToken, $desc ) { + if ( !in_array( $evilToken, $tokens ) ) { + return; + } + + if ( !isset( $this->mWarnings[$file] ) ) { + $this->mWarnings[$file] = array(); + } + $this->mWarnings[$file][] = $desc; + $this->output( "Warning in file $file: $desc found.\n" ); + } } $maintClass = "CheckSyntax"; -- 2.20.1