http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88187
Revision: 88187
Author: demon
Date: 2011-05-15 14:32:49 +0000 (Sun, 15 May 2011)
Log Message:
-----------
Add check for evil, EVIL @
Modified Paths:
--------------
trunk/phase3/maintenance/checkSyntax.php
Modified: trunk/phase3/maintenance/checkSyntax.php
===================================================================
--- trunk/phase3/maintenance/checkSyntax.php 2011-05-15 14:26:54 UTC (rev
88186)
+++ trunk/phase3/maintenance/checkSyntax.php 2011-05-15 14:32:49 UTC (rev
88187)
@@ -275,7 +275,9 @@
}
$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 @@
$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";
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs