do not evaluate '<?php' line
authorAntoine Musso <hashar@users.mediawiki.org>
Thu, 22 Dec 2011 11:06:23 +0000 (11:06 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Thu, 22 Dec 2011 11:06:23 +0000 (11:06 +0000)
This happen when you are sending to eval.php a php file. The first line
is the string '<?php' which is passed to eval(). Boom!
This patch skip that string.

Example usage:
 $ cat somefile.php
 <?php
 echo "Working!\n";
 $

 $ cat somefile.php | php maintenance/eval.php
 Working!
 $

maintenance/eval.php

index 9ad51bb..8c3bf86 100644 (file)
@@ -74,6 +74,11 @@ while ( ( $line = Maintenance::readconsole() ) !== false ) {
                readline_add_history( $line );
                readline_write_history( $historyFile );
        }
+       if( false !== strpos($line, "<?php") ) {
+               # Someone send a .php file to STDIN so we do not want
+               # to interprate the special '<?php'.
+               continue;
+       }
        $val = eval( $line . ";" );
        if ( wfIsHipHop() || is_null( $val ) ) {
                echo "\n";