mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-03-24 14:30:03 +01:00
Escapes shell arguments. See issue #197.
This commit is contained in:
parent
4cf5b13d06
commit
1f9365ae97
src/_h5ai/server/php/inc
@ -44,9 +44,9 @@ class Archive {
|
||||
|
||||
private function shell_cmd($cmd) {
|
||||
|
||||
$cmd = str_replace("[ROOTDIR]", "\"" . $this->app->get_abs_path() . "\"", $cmd);
|
||||
$cmd = str_replace("[DIRS]", count($this->dirs) ? "\"" . implode("\" \"", array_values($this->dirs)) . "\"" : "", $cmd);
|
||||
$cmd = str_replace("[FILES]", count($this->files) ? "\"" . implode("\" \"", array_values($this->files)) . "\"" : "", $cmd);
|
||||
$cmd = str_replace("[ROOTDIR]", escapeshellarg($this->app->get_abs_path()), $cmd);
|
||||
$cmd = str_replace("[DIRS]", count($this->dirs) ? implode(" ", array_map("escapeshellarg", $this->dirs)) : "", $cmd);
|
||||
$cmd = str_replace("[FILES]", count($this->files) ? implode(" ", array_map("escapeshellarg", $this->files)) : "", $cmd);
|
||||
try {
|
||||
passthru($cmd);
|
||||
} catch (Exeption $err) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
class Item {
|
||||
|
||||
private static $FOLDER_SIZE_CMD = "du -sk \"[DIR]\"";
|
||||
private static $FOLDER_SIZE_CMD = "du -sk [DIR]";
|
||||
|
||||
public static function cmp($item1, $item2) {
|
||||
|
||||
@ -57,7 +57,7 @@ class Item {
|
||||
$this->size = null;
|
||||
$options = $app->get_options();
|
||||
if ($options["foldersize"]["enabled"]) {
|
||||
$cmd = str_replace("[DIR]", $this->abs_path, Item::$FOLDER_SIZE_CMD);
|
||||
$cmd = str_replace("[DIR]", escapeshellarg($this->abs_path), Item::$FOLDER_SIZE_CMD);
|
||||
$this->size = intval(preg_replace("/\s.*$/", "", `$cmd`), 10) * 1024;
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user