1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-06-01 22:03:02 +00:00

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

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;
}