From fc4846d676536a1f52393f1c2158cc7c030223f1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 6 Dec 2011 12:23:15 -0500 Subject: [PATCH 1/4] Move overflow limits to only take effect after expiration. --- lib/Cake/Controller/Component/SecurityComponent.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Controller/Component/SecurityComponent.php b/lib/Cake/Controller/Component/SecurityComponent.php index 2a92a4f8a..6d6f91b06 100644 --- a/lib/Cake/Controller/Component/SecurityComponent.php +++ b/lib/Cake/Controller/Component/SecurityComponent.php @@ -553,16 +553,16 @@ class SecurityComponent extends Component { * @return array An array of nonce => expires. */ protected function _expireTokens($tokens) { - $now = time(); - $overflow = count($tokens) - $this->csrfLimit; - if ($overflow > 0) { - $tokens = array_slice($tokens, $overflow + 1, null, true); - } foreach ($tokens as $nonce => $expires) { if ($expires < $now) { unset($tokens[$nonce]); } } + $now = time(); + $overflow = count($tokens) - $this->csrfLimit; + if ($overflow > 0) { + $tokens = array_slice($tokens, $overflow + 1, null, true); + } return $tokens; } From 545694d84b2fd9c63d4961386e9691df6251834f Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 6 Dec 2011 12:35:18 -0500 Subject: [PATCH 2/4] Fix undefined variable error. --- lib/Cake/Controller/Component/SecurityComponent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Component/SecurityComponent.php b/lib/Cake/Controller/Component/SecurityComponent.php index 6d6f91b06..7d4be3332 100644 --- a/lib/Cake/Controller/Component/SecurityComponent.php +++ b/lib/Cake/Controller/Component/SecurityComponent.php @@ -553,12 +553,12 @@ class SecurityComponent extends Component { * @return array An array of nonce => expires. */ protected function _expireTokens($tokens) { + $now = time(); foreach ($tokens as $nonce => $expires) { if ($expires < $now) { unset($tokens[$nonce]); } } - $now = time(); $overflow = count($tokens) - $this->csrfLimit; if ($overflow > 0) { $tokens = array_slice($tokens, $overflow + 1, null, true); From 123a1a21baf307b85b9ea7e78017d02d375c1a91 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 7 Dec 2011 21:19:57 -0500 Subject: [PATCH 3/4] Fix issues with stack trace output. Traces without files and without classes caused errors in printing the fancy trace. --- lib/Cake/View/Elements/exception_stack_trace.ctp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Cake/View/Elements/exception_stack_trace.ctp b/lib/Cake/View/Elements/exception_stack_trace.ctp index 6d19ff0f4..be016757a 100644 --- a/lib/Cake/View/Elements/exception_stack_trace.ctp +++ b/lib/Cake/View/Elements/exception_stack_trace.ctp @@ -29,12 +29,14 @@ App::uses('Debugger', 'Utility'); printf( '%s line %s', $i, - $stack['file'], + Debugger::trimPath($stack['file']), $stack['line'] ); $excerpt = sprintf(' '; + else: + echo '[internal function]'; endif; echo ' → '; if ($stack['function']): @@ -43,13 +45,13 @@ App::uses('Debugger', 'Utility'); $args[] = Debugger::getType($arg); $params[] = Debugger::exportVar($arg, 2); endforeach; + + $called = isset($stack['class']) ? $stack['class'] . $stack['type'] . $stack['function'] : $stack['function']; printf( - '%s%s%s(%s) ', + '%s(%s) ', $i, - $stack['class'], - $stack['type'], - $stack['function'], + $called, implode(', ', $args) ); $arguments = sprintf('