makepathsafe: don't allow dots on their own

Specifically, we don't want a single dot as a page name. This is because 
'.' has a special meaning on Linux: The current directory.
This commit is contained in:
Starbeamrainbowlabs 2020-08-09 13:03:40 +01:00
parent 5fed4cb5ab
commit e710d55883
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
1 changed files with 2 additions and 0 deletions

View File

@ -289,6 +289,8 @@ function makepathsafe($string)
$string = preg_replace("/\.+/", ".", $string);
// Don't allow slashes at the beginning
$string = ltrim($string, "\\/");
// Don't allow dots on their own
$string = preg_replace(["/^\.\\/|\\/\.$/", "/\\/\.\\//"], ["", "/"], $string);
return $string;
}