remove some special characters from directory-names when validating, fixes #1231 and pull-request 73 partly
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -26,12 +26,12 @@
|
|||||||
*/
|
*/
|
||||||
function makeSecurePath($path) {
|
function makeSecurePath($path) {
|
||||||
|
|
||||||
$search = Array(
|
$search = array(
|
||||||
'#/+#',
|
'#/+#',
|
||||||
'#\.+#',
|
'#\.+#',
|
||||||
'#\0+#'
|
'#\0+#'
|
||||||
);
|
);
|
||||||
$replace = Array(
|
$replace = array(
|
||||||
'/',
|
'/',
|
||||||
'.',
|
'.',
|
||||||
''
|
''
|
||||||
@@ -41,5 +41,14 @@ function makeSecurePath($path) {
|
|||||||
// it might be escaped already
|
// it might be escaped already
|
||||||
$path = str_replace("\ ", " ", $path);
|
$path = str_replace("\ ", " ", $path);
|
||||||
$path = str_replace(" ", "\ ", $path);
|
$path = str_replace(" ", "\ ", $path);
|
||||||
|
|
||||||
|
// check for bad characters, some are allowed with escaping
|
||||||
|
// but we generally don't want them in our directory-names,
|
||||||
|
// thx to aaronmueller for this snipped
|
||||||
|
$badchars = array(':', ';', '|', '&', '>', '<', '`', '$', '~', '?');
|
||||||
|
foreach ($badchars as $bc) {
|
||||||
|
str_replace($bc, "", $path);
|
||||||
|
}
|
||||||
|
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user