diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-12-06 10:18:32 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-12-06 10:18:32 +0100 |
commit | 3fd3345de27c7ccd7ed1efea1805d61a66171a53 (patch) | |
tree | 3dfb679544ae12993f272f3b01644f528a07ba39 | |
parent | fd24adf31255822d6aa9a5d2dce9010ad2ee4cf0 (diff) | |
parent | 0bf9cfa127516a5561155d70a8edfa3c6b0ec57b (diff) |
Merge pull request #2055 from chernjie/develop
Bug fix for relative directory removal
-rw-r--r-- | system/core/URI.php | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/system/core/URI.php b/system/core/URI.php index 91740254c..07add5a4d 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -219,7 +219,32 @@ class CI_URI { } // Do some final cleaning of the URI and return it - return str_replace(array('//', '../'), '/', trim($uri, '/')); + return $this->_remove_relative_directory($uri); + } + + // -------------------------------------------------------------------- + + /** + * Remove relative directory (../) and multi slashes (///) + * + * Do some final cleaning of the URI and return it, currently only used in self::_parse_request_uri() + * + * @param string $url + * @return string + */ + protected function _remove_relative_directory($uri) + { + $uris = array(); + $tok = strtok($uri, '/'); + while ($tok !== FALSE) + { + if (( ! empty($tok) OR $tok === '0') && $tok !== '..') + { + $uris[] = $tok; + } + $tok = strtok('/'); + } + return implode('/', $uris); } // -------------------------------------------------------------------- |