Skip to content
Permalink
Browse files

Check whether the filter key is a valid class name before assuming th…

…at value is class settings
  • Loading branch information...
wisoot committed Sep 15, 2014
1 parent 1e29070 commit eb14a64d0ba943c54cca6f2dc5d41f6e225114ab
Showing with 11 additions and 1 deletion.
  1. +1 −1 lib/Cake/Routing/Dispatcher.php
  2. +10 −0 lib/Cake/Test/Case/Routing/DispatcherTest.php
@@ -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;
}
@@ -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(

0 comments on commit eb14a64

Please sign in to comment.
You can’t perform that action at this time.