Skip to content
Permalink
Browse files

Fixing notice errors caused by garbage urls being fed into Dispatcher.

Added a test.
Fixes #1463
  • Loading branch information...
markstory committed Jan 21, 2011
1 parent e58e3f3 commit 3747e395f118ec9c145425640b994ef8d971454b
Showing with 22 additions and 2 deletions.
  1. +2 −2 cake/dispatcher.php
  2. +20 −0 cake/tests/cases/dispatcher.test.php
@@ -264,9 +264,9 @@ function parseParams($fromUrl) {
$namedExpressions = Router::getNamedExpressions();
extract($namedExpressions);
include CONFIGS . 'routes.php';
$params = array_merge(Router::parse($fromUrl), $params);
$params = array_merge(array('controller' => '', 'action' => ''), Router::parse($fromUrl), $params);
if (strlen($params['action']) === 0) {
if (empty($params['action'])) {
$params['action'] = 'index';
}
if (isset($params['form']['data'])) {
@@ -1406,6 +1406,26 @@ function testDispatchWithArray() {
$this->assertEqual($Dispatcher->base . '/pages/display/home/param:value/param2:value2', $Dispatcher->here);
}
/**
* test that a garbage url doesn't cause errors.
*
* @return void
*/
function testDispatchWithGarbageUrl() {
Configure::write('App.baseUrl', '/index.php');
$Dispatcher =& new TestDispatcher();
$url = 'http://google.com';
$result = $Dispatcher->dispatch($url);
$expected = array('missingController', array(array(
'className' => 'Controller',
'webroot' => '/',
'url' => 'http://google.com',
'base' => '/index.php'
)));
$this->assertEqual($expected, $result);
}
/**
* testAdminDispatch method
*

0 comments on commit 3747e39

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.