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