Permalink
Browse files

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

  • Loading branch information...
1 parent 75857b5 commit b7b6859c274d3f5ec64b204cab74fb07b85c8355 @bfanger bfanger committed Dec 21, 2012
Showing with 9 additions and 1 deletion.
  1. +5 −1 lib/Cake/Network/CakeRequest.php
  2. +4 −0 lib/Cake/Test/Case/Network/CakeRequestTest.php
View
6 lib/Cake/Network/CakeRequest.php
@@ -232,7 +232,11 @@ protected function _url() {
} 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
4 lib/Cake/Test/Case/Network/CakeRequestTest.php
@@ -136,6 +136,10 @@ public function testQueryStringAndNamedParams() {
$_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);
}
/**

0 comments on commit b7b6859

Please sign in to comment.