modified the security helper to assist in preventing directory traversal when using sanitize_filename() for user input
diff --git a/system/libraries/Security.php b/system/libraries/Security.php
index 9a1590b..3c1e9cf 100644
--- a/system/libraries/Security.php
+++ b/system/libraries/Security.php
@@ -680,11 +680,10 @@
* @param string
* @return string
*/
- function sanitize_filename($str)
+ function sanitize_filename($str, $relative_path = FALSE)
{
$bad = array(
"../",
- "./",
"<!--",
"-->",
"<",
@@ -701,7 +700,6 @@
'=',
';',
'?',
- '/',
"%20",
"%22",
"%3c", // <
@@ -717,6 +715,12 @@
"%3b", // ;
"%3d" // =
);
+
+ if ( ! $relative_path)
+ {
+ $bad[] = './';
+ $bad[] = '/';
+ }
return stripslashes(str_replace($bad, '', $str));
}