From 661f588a010fd9203d542398e04997902405c122 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Thu, 10 Jan 2013 16:26:59 +0100 Subject: URI->_remove_url_suffix() : suffix has to be at the end of uri_string related to #2135 --- system/core/URI.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/system/core/URI.php b/system/core/URI.php index b3603bbb1..8d0d8fddc 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -353,9 +353,16 @@ class CI_URI { { $suffix = (string) $this->config->item('url_suffix'); - if ($suffix !== '' && ($offset = strrpos($this->uri_string, $suffix)) !== FALSE) + if ($suffix === '') { - $this->uri_string = substr_replace($this->uri_string, '', $offset, strlen($suffix)); + return; + } + + $offset = strrpos($this->uri_string, $suffix); + + if ($offset !== FALSE && $offset === strlen($this->uri_string) - strlen($suffix)) + { + $this->uri_string = substr($this->uri_string, 0, $offset); } } -- cgit v1.2.3-24-g4f1b From d1e50fa4ae25a8e60a13f06e6debbca1b2749fce Mon Sep 17 00:00:00 2001 From: vlakoff Date: Fri, 11 Jan 2013 15:22:17 +0100 Subject: URI->_remove_url_suffix() : more efficient code related to #2135 --- system/core/URI.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/core/URI.php b/system/core/URI.php index 8d0d8fddc..9b31a646b 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -358,11 +358,11 @@ class CI_URI { return; } - $offset = strrpos($this->uri_string, $suffix); + $slen = strlen($suffix); - if ($offset !== FALSE && $offset === strlen($this->uri_string) - strlen($suffix)) + if (substr($this->uri_string, -$slen) === $suffix) { - $this->uri_string = substr($this->uri_string, 0, $offset); + $this->uri_string = substr($this->uri_string, 0, -$slen); } } -- cgit v1.2.3-24-g4f1b