Skip to content

Commit d1d3de0

Browse files
fix: escape glob metacharacters in both tmp directory and filename for countChunks
1 parent a42a2c6 commit d1d3de0

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/Storage/Device/Local.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,10 @@ public function uploadData(string $data, string $path, string $contentType, int
143143

144144
private function countChunks(string $tmp, string $path): int
145145
{
146-
$filename = \str_replace(['\\', '*', '?', '[', ']', '{', '}'], ['\\\\', '\\*', '\\?', '\\[', '\\]', '\\{', '\\}'], \pathinfo($path, PATHINFO_FILENAME));
147-
$pattern = $tmp.DIRECTORY_SEPARATOR.$filename.'.part.*';
146+
$escaped = function (string $literal): string {
147+
return \str_replace(['\\', '*', '?', '[', ']', '{', '}'], ['\\\\', '\\*', '\\?', '\\[', '\\]', '\\{', '\\}'], $literal);
148+
};
149+
$pattern = $escaped($tmp).DIRECTORY_SEPARATOR.$escaped(\pathinfo($path, PATHINFO_FILENAME)).'.part.*';
148150
$files = \glob($pattern);
149151
if ($files === false) {
150152
return 0;

0 commit comments

Comments
 (0)