summaryrefslogtreecommitdiffstats
path: root/system/core/URI.php
diff options
context:
space:
mode:
authorbrian978 <dbrian89@yahoo.com>2012-12-09 10:20:01 +0100
committerbrian978 <dbrian89@yahoo.com>2012-12-09 10:20:01 +0100
commit2c70fec8c697caaea0ee74392847a6a6204eea01 (patch)
treef7ecd946cdf2c4f66997d1f0677061a34afc6d0e /system/core/URI.php
parentd56eb54f0f7a058d9e1b253f8fb900680d6813e0 (diff)
parent545a7c86701875e1412bcde316e9bcc76d9a23a0 (diff)
Merge remote-tracking branch 'upstream/develop' into develop
Diffstat (limited to 'system/core/URI.php')
-rw-r--r--system/core/URI.php29
1 files changed, 27 insertions, 2 deletions
diff --git a/system/core/URI.php b/system/core/URI.php
index 91740254c..900472b61 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);
}
// --------------------------------------------------------------------
@@ -249,7 +274,7 @@ class CI_URI {
parse_str($_SERVER['QUERY_STRING'], $_GET);
- return str_replace(array('//', '../'), '/', trim($uri, '/'));
+ return $this->_remove_relative_directory($uri);
}
// --------------------------------------------------------------------