Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…coded characters
  • Loading branch information...
commit 8305eaaf03e1a3c5e9c11dad55aecb49c9e37fae 1 parent 03a9547
Josh Lockhart authored
Showing with 18 additions and 0 deletions.
  1. +18 −0 tests/EnvironmentTest.php
View
18 tests/EnvironmentTest.php
@@ -205,6 +205,24 @@ public function testRemovesQueryStringFromPathInfo() {
}
/**
+ * 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
*
* Pre-conditions:
Please sign in to comment.
Something went wrong with that request. Please try again.