From bb879da388c34b213a1cd35bf8400a9da2023d68 Mon Sep 17 00:00:00 2001 From: nate Date: Wed, 6 Feb 2008 17:22:39 +0000 Subject: [PATCH] A fixing Dispatcher handling for GET vars when request is made from domain base, fixes #3856 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6442 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/dispatcher.php | 6 ++++-- cake/tests/cases/dispatcher.test.php | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 2af1f337e..a86bc626c 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -566,9 +566,11 @@ class Dispatcher extends Object { if ($base) { $uri = preg_replace('/^(?:\/)?(?:' . preg_quote($base, '/') . ')?(?:url=)?/', '', $uri); } - $uri = preg_replace('/^(?:\/)?(?:index\.php)?(?:\/)?(?:\?)?(?:url=)?/', '', $uri); - if (Configure::read('App.server') == 'IIS' && !empty($uri)) { + if (Configure::read('App.server') == 'IIS') { + $uri = preg_replace('/^(?:\/)?(?:\/)?(?:\?)?(?:url=)?/', '', $uri); + } + if (!empty($uri)) { if (key($_GET) && strpos(key($_GET), '?') !== false) { unset($_GET[key($_GET)]); } diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index e83d76f50..fa2a7242d 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -1082,6 +1082,15 @@ class DispatcherTest extends UnitTestCase { 'SERVER' => array('UNIQUE_ID' => 'VardGqn@17IAAAu7LY8AAAAK', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-us) AppleWebKit/523.10.5 (KHTML, like Gecko) Version/3.0.4 Safari/523.10.6', 'HTTP_ACCEPT' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_CONNECTION' => 'keep-alive', 'HTTP_HOST' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/officespace/app/webroot/index.php', 'QUERY_STRING' => '', 'REQUEST_URI' => '/index.php/posts/add', 'SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '/posts/add', 'PHP_SELF' => '/index.php/posts/add', 'argv' => array(), 'argc' => 0), 'reload' => false, 'path' => '/posts/add' + ), + 'GET Request at base domain' => array( + 'App' => array('base' => false, 'baseUrl' => null, 'dir' => 'app', 'webroot' => 'webroot'), + 'SERVER' => array('UNIQUE_ID' => '2A-v8sCoAQ8AAAc-2xUAAAAB', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_COOKIE' => 'CAKEPHP=jcbv51apn84kd9ucv5aj2ln3t3', 'HTTP_CONNECTION' => 'keep-alive', 'HTTP_HOST' => 'cake.1.2', 'SERVER_NAME' => 'cake.1.2', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '127.0.0.1', 'DOCUMENT_ROOT' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot', 'SERVER_ADMIN' => 'you@example.com', 'SCRIPT_FILENAME' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot/index.php', 'REMOTE_PORT' => '53550', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => 'a=b', 'REQUEST_URI' => '/?a=b', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php'), + 'GET' => array('a' => 'b'), + 'POST' => array(), + 'reload' => true, + 'path' => '', + 'urlParams' => array('a' => 'b') ) ) ); @@ -1094,6 +1103,9 @@ class DispatcherTest extends UnitTestCase { } $this->__loadEnvironment($settings); $this->assertEqual($dispatcher->uri(), $settings['path'], "%s on environment: {$name}, on setting: {$descrip}"); + if (isset($setting['urlParams'])) { + $this->assertEqual($_GET, $settings['urlParams'], "%s on environment: {$name}, on setting: {$descrip}"); + } } } $this->__loadEnvironment(array_merge(array('reload' => true), $backup));