Skip to content

Commit 2964ff5

Browse files
authored
[BUGFIX] sanitize filename
1 parent ee2ce2e commit 2964ff5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Snapshot.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ public function id(): string
4040

4141
public function filename(): string
4242
{
43-
return $this->id.'.'.$this->driver->extension();
43+
$file = $this->id.'.'.$this->driver->extension();
44+
// Remove anything which isn't a word, whitespace, number
45+
// or any of the following caracters -_~,;[]().
46+
$file = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $file);
47+
// Remove any runs of periods
48+
$file = mb_ereg_replace("([\.]{2,})", '', $file);
49+
return $file;
4450
}
4551

4652
public function exists(): bool

0 commit comments

Comments
 (0)