Fixes corrupted CakeRequests when a $_GET value contains "://"

This commit is contained in:
Bob Fanger 2012-12-21 16:12:51 +01:00
parent 75857b5e36
commit b7b6859c27
2 changed files with 9 additions and 1 deletions

View file

@ -232,7 +232,11 @@ class CakeRequest implements ArrayAccess {
} elseif (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '://') === false) {
$uri = $_SERVER['REQUEST_URI'];
} elseif (isset($_SERVER['REQUEST_URI'])) {
$uri = substr($_SERVER['REQUEST_URI'], strlen(FULL_BASE_URL));
if (strpos($_SERVER['REQUEST_URI'], '?') !== false && strpos($_SERVER['REQUEST_URI'], '://') > strpos($_SERVER['REQUEST_URI'], '?')) {
$uri = $_SERVER['REQUEST_URI'];
} else {
$uri = substr($_SERVER['REQUEST_URI'], strlen(FULL_BASE_URL));
}
} elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['SCRIPT_NAME'])) {
$uri = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['PHP_SELF']);
} elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) {

View file

@ -136,6 +136,10 @@ class CakeRequestTest extends CakeTestCase {
$_SERVER['REQUEST_URI'] = '/tasks/index/page:1/?ts=123456';
$request = new CakeRequest();
$this->assertEquals('tasks/index/page:1/', $request->url);
$_SERVER['REQUEST_URI'] = '/some/path?url=http://cakephp.org';
$request = new CakeRequest();
$this->assertEquals('some/path', $request->url);
}
/**