diff options
-rw-r--r-- | system/core/URI.php | 7 | ||||
-rw-r--r-- | tests/codeigniter/core/URI_test.php | 12 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 1 |
3 files changed, 9 insertions, 11 deletions
diff --git a/system/core/URI.php b/system/core/URI.php index 6a8b1a5ac..15e6a5599 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -165,11 +165,8 @@ class CI_URI { */ protected function _set_uri_string($str) { - // Filter out control characters - $str = remove_invisible_characters($str, FALSE); - - // If the URI contains only a slash we'll kill it - $this->uri_string = ($str === '/') ? '' : $str; + // Filter out control characters and trim slashes + $this->uri_string = trim(remove_invisible_characters($str, FALSE), '/'); } // -------------------------------------------------------------------- diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php index 60ed1a4e9..e2deabe51 100644 --- a/tests/codeigniter/core/URI_test.php +++ b/tests/codeigniter/core/URI_test.php @@ -40,13 +40,13 @@ class URI_test extends CI_TestCase { '/index.php?/controller/method/?var=foo' => 'controller/method' ); - foreach($requests as $request => $expected) + foreach ($requests as $request => $expected) { $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['REQUEST_URI'] = $request; $this->uri->_fetch_uri_string(); - $this->assertEquals($expected, $this->uri->uri_string ); + $this->assertEquals($expected, $this->uri->uri_string); } // Test a subfolder @@ -60,10 +60,10 @@ class URI_test extends CI_TestCase { unset($_SERVER['REQUEST_URI']); // life to path info - $_SERVER['PATH_INFO'] = $a = '/controller/method/'; + $_SERVER['PATH_INFO'] = '/controller/method/'; $this->uri->_fetch_uri_string(); - $this->assertEquals($a, $this->uri->uri_string); + $this->assertEquals('controller/method', $this->uri->uri_string); // death to path info // At this point your server must be seriously drunk @@ -72,7 +72,7 @@ class URI_test extends CI_TestCase { $_SERVER['QUERY_STRING'] = '/controller/method/'; $this->uri->_fetch_uri_string(); - $this->assertEquals($a, $this->uri->uri_string); + $this->assertEquals('controller/method', $this->uri->uri_string); // At this point your server is a labotomy victim unset($_SERVER['QUERY_STRING']); @@ -80,7 +80,7 @@ class URI_test extends CI_TestCase { $_GET['/controller/method/'] = ''; $this->uri->_fetch_uri_string(); - $this->assertEquals($a, $this->uri->uri_string); + $this->assertEquals('controller/method', $this->uri->uri_string); // Test coverage implies that these will work // uri_protocol: REQUEST_URI diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index cd503785c..f0a61d45d 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -372,6 +372,7 @@ Bug fixes for 3.0 - Fixed a bug where :doc:`Email Library <libraries/email>` didn't honor it's *wordwrap* setting while handling alternative messages. - Fixed a bug (#1476, #1909) - :doc:`Pagination Library <libraries/pagination>` didn't take into account actual routing when determining the current page. - Fixed a bug (#1766) - :doc:`Query Builder <database/query_builder>` didn't always take into account the *dbprefix* setting. +- Fixed a bug (#779) - :doc:`URI Class <libraries/uri>` didn't always trim slashes from the *uri_string* as shown in the documentation. Version 2.1.3 ============= |