This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
Incam_SGD/tests/util/ktutil/testSafeShellString.php

35 lines
935 B
PHP

<?php
require_once("../../../config/dmsDefaults.php");
require_once(KT_LIB_DIR . "/util/ktutil.inc");
$aSource = array(
array('unzip', "-q", "-j", "-n", "-d", '/tmp', '5 July 2005 Pricelist - Rectron(cpt).zip'),
array('unzip', "-q", "-j", "-n", "-d", '/tmp', "5'th July 2005 Pricelist - Rectron(cpt).zip"),
array('echo', ''),
array('echo', ' '),
);
$aExpectedResults = array(
"'unzip' '-q' '-j' '-n' '-d' '/tmp' '5 July 2005 Pricelist - Rectron(cpt).zip'",
"'unzip' '-q' '-j' '-n' '-d' '/tmp' '5'\''th July 2005 Pricelist - Rectron(cpt).zip'",
"'echo' ''",
"'echo' ' '",
);
$aResults = array();
foreach ($aSource as $aArgs) {
$aResults[] = KTUtil::safeShellString($aArgs);
}
if ($aResults === $aExpectedResults) {
print "Success!\n";
} else {
print "Failure!\n";
print "Received: " . print_r($aResults, true) . "\n";
print "Expected: " . print_r($aExpectedResults, true) . "\n";
}
?>