private function getCommand($pattern, $sudo, $director, $bconsole_command) {
$command = array('cmd' => null, 'out_id' => null);
+ $misc = $this->getModule('misc');
if ($pattern === self::BCONSOLE_BG_COMMAND_PATTERN || $pattern === self::BCONSOLE_CONFIRM_YES_BG_COMMAND_PATTERN) {
$file = $this->prepareOutputFile();
$cmd = sprintf(
$director,
$file
);
- $command['cmd'] = $cmd;
+ $command['cmd'] = $misc->escapeCharsToConsole($cmd);
$command['out_id'] = preg_replace('/^[\s\S]+\/output_/', '', $file);
} else {
$cmd = sprintf(
$director,
$bconsole_command
);
- $command['cmd'] = $cmd;
+ $command['cmd'] = $misc->escapeCharsToConsole($cmd);
$command['out_id'] = '';
}
return $command;
self::getCmdPath(),
self::getCfgPath()
);
+ $cmd = $this->getModule('misc')->escapeCharsToConsole($cmd);
exec($cmd, $output, $exitcode);
if($exitcode != 0) {
$emsg = ' Output=>' . implode("\n", $output) . ', Exitcode=>' . $exitcode;
}
public function isValidPath($path) {
- return (preg_match('/^[\p{L}\p{N}\p{Z}\[\]\(\)\-\+\/\\\:\.#~_,{}!\']{0,10000}$/u', $path) === 1);
+ return (preg_match('/^[\p{L}\p{N}\p{Z}\[\]\-\'\/\\(){}:.#~_,+!$]{0,10000}$/u', $path) === 1);
}
public function isValidReplace($replace) {
return (preg_match('/^[a-zA-Z0-9]+$/', $str) === 1);
}
+ public function escapeCharsToConsole($path) {
+ return preg_replace('/([$])/', '\\\${1}', $path);
+ }
+
/**
* Writing INI-style configuration file.