r101057 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101056‎ | r101057 | r101058 >
Date:21:18, 27 October 2011
Author:platonides
Status:ok
Tags:
Comment:
Convert the string to single quoted and manually escape it.
http://us.php.net/manual/en/language.types.string.php

addslashes() is convenient, but this way we have no legitimate
usage, and it's easier to have it banned everywhere.
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php
@@ -24,7 +24,7 @@
2525 */
2626 $className = str_replace( '.', '_', ucfirst( basename( $filename, '.txt' ) ) );
2727
28 - eval( "/** @group Database\n@group Parser\n*/ class $className extends NewParserTest { protected \$file = \"" . addslashes( $filename ) . "\"; } " );
 28+ eval( "/** @group Database\n@group Parser\n*/ class $className extends NewParserTest { protected \$file = '" . strtr( $filename, array( "'" => "\\'", '\\' => '\\\\' ) ) . "'; } " );
2929
3030 $parserTester = new $className( $testsName );
3131 $suite->addTestSuite( new ReflectionClass ( $parserTester ) );

Status & tagging log