Permalink
Browse files

Add unit test to ensure Slim_Environment URIs correctly retain URL en…

…coded characters
  • Loading branch information...
Josh Lockhart
Josh Lockhart committed Apr 8, 2012
1 parent 03a9547 commit 8305eaaf03e1a3c5e9c11dad55aecb49c9e37fae
Showing with 18 additions and 0 deletions.
  1. +18 −0 tests/EnvironmentTest.php
View
@@ -204,6 +204,24 @@ public function testRemovesQueryStringFromPathInfo() {
$this->assertEquals('/bar/xyz', $env['PATH_INFO']);
}
+ /**
+ * Test environment's PATH_INFO retains URL encoded characters (e.g. #)
+ *
+ * In earlier version, Slim_Environment would use PATH_INFO instead
+ * of REQUEST_URI to determine the root URI and resource URI.
+ * Unfortunately, the server would URL decode the PATH_INFO string
+ * before it was handed to PHP. This prevented certain URL-encoded
+ * characters like the octothorpe from being delivered correctly to
+ * the Slim application environment. This test ensures the
+ * REQUEST_URI is used instead and parsed as expected.
+ */
+ public function testPathInfoRetainsUrlEncodedCharacters() {
+ $_SERVER['SCRIPT_NAME'] = '/index.php';
+ $_SERVER['REQUEST_URI'] = '/foo/%23bar'; //<-- URL-encoded "#bar"
+ $env = Slim_Environment::getInstance(true);
+ $this->assertEquals('/foo/%23bar', $env['PATH_INFO']);
+ }
+
/**
* Test parses query string
*

0 comments on commit 8305eaa

Please sign in to comment.