Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Handle REQUEST_URI with domain names properly.

Don't depend on parse_url() as it fails with corrupted urls.  Instead
use FULL_BASE_URL to prepare an absolute path.

Fixes #3270
  • Loading branch information...
commit 59f84024e558169b2a79b395779971fce7fa7055 1 parent 513851d
Mark Story markstory authored
4 lib/Cake/Network/CakeRequest.php
View
@@ -229,8 +229,10 @@ protected function _processGet() {
protected function _url() {
if (!empty($_SERVER['PATH_INFO'])) {
return $_SERVER['PATH_INFO'];
- } elseif (isset($_SERVER['REQUEST_URI'])) {
+ } 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));
} 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'])) {
24 lib/Cake/Test/Case/Network/CakeRequestTest.php
View
@@ -1647,6 +1647,30 @@ public static function environmentGenerator() {
),
),
array(
+ 'Apache - w/rewrite, document root set above top level cake dir, request root, absolute REQUEST_URI',
+ array(
+ 'App' => array(
+ 'base' => false,
+ 'baseUrl' => false,
+ 'dir' => 'app',
+ 'webroot' => 'webroot'
+ ),
+ 'SERVER' => array(
+ 'SERVER_NAME' => 'localhost',
+ 'DOCUMENT_ROOT' => '/Library/WebServer/Documents',
+ 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php',
+ 'REQUEST_URI' => FULL_BASE_URL . '/site/posts/index',
+ 'SCRIPT_NAME' => '/site/app/webroot/index.php',
+ 'PHP_SELF' => '/site/app/webroot/index.php',
+ ),
+ ),
+ array(
+ 'url' => 'posts/index',
+ 'base' => '/site',
+ 'webroot' => '/site/',
+ ),
+ ),
+ array(
'Nginx - w/rewrite, document root set to webroot, request root, no PATH_INFO',
array(
'App' => array(
Please sign in to comment.
Something went wrong with that request. Please try again.