mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-12-02 03:46:17 +00:00
f52136eada
PHP can't handle having arrays/objects or functions as keys in its arrays, so make sure we don't try to pass them from Lua. Booleans aren't really well-handled either, so let's disallow them too. Also, add tests for proper stringification of floats and infinities when those are used as keys. Note this behavior change is needed to match the change in LuaSandbox for fixing bug 54527, but isn't itself a security issue. Change-Id: I1e2951bbe8cb78358650ad377bf7119fcac4485d
28 lines
735 B
PHP
28 lines
735 B
PHP
<?php
|
|
|
|
class Scribunto_LuaStandaloneTests extends Scribunto_LuaEngineTestBase {
|
|
protected static $moduleName = 'StandaloneTests';
|
|
|
|
public static function suite( $className ) {
|
|
return self::makeSuite( $className, 'LuaStandalone' );
|
|
}
|
|
|
|
public function setUp() {
|
|
parent::setUp();
|
|
|
|
$interpreter = $this->getEngine()->getInterpreter();
|
|
$func = $interpreter->wrapPhpFunction( function ( $v ) {
|
|
return array( preg_replace( '/\s+/', ' ', trim( var_export( $v, 1 ) ) ) );
|
|
} );
|
|
$interpreter->callFunction(
|
|
$interpreter->loadString( 'mw.var_export = ...', 'fortest' ), $func
|
|
);
|
|
}
|
|
|
|
function getTestModules() {
|
|
return parent::getTestModules() + array(
|
|
'StandaloneTests' => __DIR__ . '/StandaloneTests.lua',
|
|
);
|
|
}
|
|
}
|