summaryrefslogtreecommitdiff
path: root/tests/exec.t
blob: 689bd269fc8acc5dfe85494e37fab788adf6d1c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/www/server/bin/php -qC
<?php

# Tests for getopt in it.class

is(it::exec("echo gna"), "gna\n", "basic exec");
is(it::exec("echo {arg}", array('arg' => 'gna')), "gna\n", "exec with argument");
is(it::shell_command("echo {arg}", array('arg' => 'gna07,-:blah')), "echo gna07,-:blah", "don't quote arguments with only whitelistes characters");
is(it::shell_command("echo {arg}", array('arg' => '2>&1')), "echo '2>&1'", "quote arguments with dangerous characters");
is(it::shell_command("echo {arg}", array('arg' => '')), "echo ''", "quote empty arguments");

foreach (array("", "C", "de_CH", "de_CH.utf8") as $locale) {
	setlocale(LC_ALL, $locale);
	$arg = "preüpost";
	if (it::match('utf8', $locale))
		$arg = utf8_encode($arg);
	is(it::exec("echo " . $arg), $arg . "\n", "exec with umlaut (locale '$locale')");
	is(it::exec("echo {arg}", array('arg' => $arg)), $arg . "\n", "exec with argument and umlaut (locale '$locale')");
}

is(it::_exec_quotevalue(""), "''", "empty arg needs quotes");
is(it::_exec_quotevalue("*"), "'*'", "special chars need quotes");
is(it::_exec_quotevalue("Aabcdef0123456789"), "Aabcdef0123456789", "simple case. tel:debug_getdata needs unquoted vals");