From cdc764e22113b9e0dd2cc213fbe0724b575ab8c7 Mon Sep 17 00:00:00 2001 From: Yurii Myronchuk Date: Fri, 21 Nov 2025 14:37:06 +0100 Subject: [PATCH 1/3] HP-2667: Do not prevent exception when name is empty --- src/FileStorage.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/FileStorage.php b/src/FileStorage.php index 0b030cb..9e028a3 100644 --- a/src/FileStorage.php +++ b/src/FileStorage.php @@ -21,11 +21,18 @@ public function __construct($path = null) protected function getFullPath($name) { + if (empty($name)) { + return null; + } return $this->path . '/' . $name[0] . '/' . $name; } public function has($name) { + $path = $this->getFullPath($name); + if ($path === null) { + return false; + } return is_file($this->getFullPath($name)); } @@ -68,6 +75,10 @@ public function remove($name) { $path = $this->getFullPath($name); + if ($path === null) { + return true; + } + return unlink($path); } } From 24c21a3ab6a5aeed96e1e681edec20b2334188c8 Mon Sep 17 00:00:00 2001 From: Yurii Myronchuk Date: Mon, 24 Nov 2025 15:23:59 +0100 Subject: [PATCH 2/3] change --- src/FileStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FileStorage.php b/src/FileStorage.php index 9e028a3..6539199 100644 --- a/src/FileStorage.php +++ b/src/FileStorage.php @@ -21,7 +21,7 @@ public function __construct($path = null) protected function getFullPath($name) { - if (empty($name)) { + if ($name === null || $name === '' || !is_string($name)) { return null; } return $this->path . '/' . $name[0] . '/' . $name; From 5801629aa0ad7c4eecd991b885fdb4daa25217fe Mon Sep 17 00:00:00 2001 From: Yurii Myronchuk Date: Mon, 24 Nov 2025 15:31:38 +0100 Subject: [PATCH 3/3] change --- src/FileStorage.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/FileStorage.php b/src/FileStorage.php index 6539199..a2a2cfe 100644 --- a/src/FileStorage.php +++ b/src/FileStorage.php @@ -21,10 +21,11 @@ public function __construct($path = null) protected function getFullPath($name) { - if ($name === null || $name === '' || !is_string($name)) { - return null; + if (is_string($name) && $name !== '') { + return $this->path . '/' . $name[0] . '/' . $name; } - return $this->path . '/' . $name[0] . '/' . $name; + + return null; } public function has($name)