Skip to content

Commit

Permalink
Add unit test to ensure Slim_Environment URIs correctly retain URL en…
Browse files Browse the repository at this point in the history
…coded characters
  • Loading branch information
Josh Lockhart committed Apr 8, 2012
1 parent 03a9547 commit 8305eaa
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/EnvironmentTest.php
Expand Up @@ -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
*
Expand Down

0 comments on commit 8305eaa

Please sign in to comment.