summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-12-06 10:18:32 +0100
committerAndrey Andreev <narf@bofh.bg>2012-12-06 10:18:32 +0100
commit3fd3345de27c7ccd7ed1efea1805d61a66171a53 (patch)
tree3dfb679544ae12993f272f3b01644f528a07ba39
parentfd24adf31255822d6aa9a5d2dce9010ad2ee4cf0 (diff)
parent0bf9cfa127516a5561155d70a8edfa3c6b0ec57b (diff)
Merge pull request #2055 from chernjie/develop
Bug fix for relative directory removal
-rw-r--r--system/core/URI.php27
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);
}
// --------------------------------------------------------------------