From eb14a64d0ba943c54cca6f2dc5d41f6e225114ab Mon Sep 17 00:00:00 2001 From: wisoot Date: Mon, 15 Sep 2014 15:29:30 +1000 Subject: [PATCH] Check whether the filter key is a valid class name before assuming that value is class settings --- lib/Cake/Routing/Dispatcher.php | 2 +- lib/Cake/Test/Case/Routing/DispatcherTest.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Routing/Dispatcher.php b/lib/Cake/Routing/Dispatcher.php index e4d3a8eec24..d7c66c77593 100644 --- a/lib/Cake/Routing/Dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.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; } diff --git a/lib/Cake/Test/Case/Routing/DispatcherTest.php b/lib/Cake/Test/Case/Routing/DispatcherTest.php index 8364c8ac04c..ef0eefe5eb4 100644 --- a/lib/Cake/Test/Case/Routing/DispatcherTest.php +++ b/lib/Cake/Test/Case/Routing/DispatcherTest.php @@ -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(