From a679750e03de9abaed8a323533b896d8a1f10d2b Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 20 Aug 2008 11:29:08 +0000 Subject: Refs #273: Extra sanity checking on install git-svn-id: https://code.elgg.org/elgg/trunk@2025 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/input.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'engine/lib/input.php') diff --git a/engine/lib/input.php b/engine/lib/input.php index 187242f8e..4b36393d8 100644 --- a/engine/lib/input.php +++ b/engine/lib/input.php @@ -63,6 +63,25 @@ $CONFIG->input = array(); $CONFIG->input[trim($variable)] = trim($value); + } + + /** + * Sanitise file paths for input, ensuring that they begin and end with slashes etc. + * + * @param string $path The path + * @return string + */ + function sanitise_filepath($path) + { + // Convert to correct UNIX paths + $path = str_replace('\\', '/', $path); + + // Sort trailing slash + $path = trim($path); + $path = rtrim($path, " /"); + $path = $path . "/"; + + return $path; } /** -- cgit v1.2.3