Skip to content

Commit

Permalink
Check whether the filter key is a valid class name before assuming th…
Browse files Browse the repository at this point in the history
…at value is class settings
  • Loading branch information
wisoot committed Sep 15, 2014
1 parent 1e29070 commit eb14a64
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/Routing/Dispatcher.php
Expand Up @@ -97,7 +97,7 @@ protected function _attachFilters($manager) {

foreach ($filters as $index => $filter) {
$settings = array();
if (is_array($filter) && !is_int($index)) {
if (is_array($filter) && !is_int($index) && class_exists($index)) {
$settings = $filter;
$filter = $index;
}
Expand Down
10 changes: 10 additions & 0 deletions lib/Cake/Test/Case/Routing/DispatcherTest.php
Expand Up @@ -1328,6 +1328,16 @@ public function testDispatcherFilterCallable() {
$dispatcher->dispatch($request, $response);
$this->assertEquals('Dispatcher.afterDispatch', $request->params['eventName']);

$dispatcher = new TestDispatcher();
Configure::write('Dispatcher.filters', array(
'filterTest' => array('callable' => array($dispatcher, 'filterTest'), 'on' => 'before')
));

$request = new CakeRequest('/');
$response = $this->getMock('CakeResponse', array('send'));
$dispatcher->dispatch($request, $response);
$this->assertEquals('Dispatcher.beforeDispatch', $request->params['eventName']);

// Test that it is possible to skip the route connection process
$dispatcher = new TestDispatcher();
Configure::write('Dispatcher.filters', array(
Expand Down

0 comments on commit eb14a64

Please sign in to comment.