5use Wikimedia\TestingAccessWrapper;
13 use MediaWikiCoversValidator;
16 $this->assertInternalType(
'bool', Shell::isDisabled() );
24 $this->markTestSkipped(
'This test requires a POSIX environment.' );
26 $this->assertSame( $expected, call_user_func_array( [ Shell::class,
'escape' ],
$args ) );
31 'simple' => [ [
'true' ],
"'true'" ],
32 'with args' => [ [
'convert',
'-font',
'font name' ],
"'convert' '-font' 'font name'" ],
33 'array' => [ [ [
'convert',
'-font',
'font name' ] ],
"'convert' '-font' 'font name'" ],
34 'skip nulls' => [ [
'ls', null ],
"'ls'" ],
66 ->unsafeParams(
'unsafe' );
70 $wrapper = TestingAccessWrapper::newFromObject(
$command );
73 $this->assertEquals( $expectedWin, $wrapper->command );
75 $this->assertEquals( $expected, $wrapper->command );
77 $this->assertSame( 0, $wrapper->restrictions & Shell::NO_LOCALSETTINGS );
85 "'$wgPhpCli' 'maintenance/foobar.php' 'bar'\\''\"baz' 'safe' unsafe",
86 '"' .
$wgPhpCli .
'" "maintenance/foobar.php" "bar\'\\"baz" "safe" unsafe',
87 'maintenance/foobar.php',
91 "'$wgPhpCli' 'changed.php' '--wiki=somewiki' 'bar'\\''\"baz' 'safe' unsafe",
92 '"' .
$wgPhpCli .
'" "changed.php" "--wiki=somewiki" "bar\'\\"baz" "safe" unsafe',
93 'maintenance/foobar.php',
96 function ( &$script, array &$parameters ) {
97 $script =
'changed.php';
98 array_unshift( $parameters,
'--wiki=somewiki' );
102 "'/bin/perl' 'maintenance/foobar.php' 'bar'\\''\"baz' 'safe' unsafe",
103 '"/bin/perl" "maintenance/foobar.php" "bar\'\\"baz" "safe" unsafe',
104 'maintenance/foobar.php',
106 [
'php' =>
'/bin/perl' ],
109 "'$wgPhpCli' 'foobinize' 'maintenance/foobar.php' 'bar'\\''\"baz' 'safe' unsafe",
110 '"' .
$wgPhpCli .
'" "foobinize" "maintenance/foobar.php" "bar\'\\"baz" "safe" unsafe',
111 'maintenance/foobar.php',
113 [
'wrapper' =>
'foobinize' ],
$wgPhpCli
Executable path of the PHP cli binary.
wfIsWindows()
Check if the operating system is Windows.
\MediaWiki\Shell\Shell Shell
testEscape( $args, $expected)
provideEscape
testMakeScriptCommand( $expected, $expectedWin, $script, $parameters, $options=[], $hook=null)
\MediaWiki\Shell\Shell::makeScriptCommand provideMakeScriptCommand
provideMakeScriptCommand()
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options