diff options
author | Derek Jones <derek.jones@ellislab.com> | 2010-10-07 00:51:59 +0200 |
---|---|---|
committer | Derek Jones <derek.jones@ellislab.com> | 2010-10-07 00:51:59 +0200 |
commit | 2ef375969b77c5fdf84118d4a7a8e0bc97d9d2f6 (patch) | |
tree | c9a3a7f9c53d3cd0392c982e6fb54e992c40eb65 /system/libraries/Security.php | |
parent | 2615e418539c3d6e2f912c66be99ffebfb8513ff (diff) |
modified the security helper to assist in preventing directory traversal when using sanitize_filename() for user input
Diffstat (limited to 'system/libraries/Security.php')
-rw-r--r-- | system/libraries/Security.php | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/system/libraries/Security.php b/system/libraries/Security.php index 9a1590b5c..3c1e9cfba 100644 --- a/system/libraries/Security.php +++ b/system/libraries/Security.php @@ -680,11 +680,10 @@ class CI_Security { * @param string * @return string */ - function sanitize_filename($str) + function sanitize_filename($str, $relative_path = FALSE) { $bad = array( "../", - "./", "<!--", "-->", "<", @@ -701,7 +700,6 @@ class CI_Security { '=', ';', '?', - '/', "%20", "%22", "%3c", // < @@ -717,6 +715,12 @@ class CI_Security { "%3b", // ; "%3d" // = ); + + if ( ! $relative_path) + { + $bad[] = './'; + $bad[] = '/'; + } return stripslashes(str_replace($bad, '', $str)); } |