Skip to content
Permalink
Browse files

Fixing method coercion in error404 so it only coerces CakeExceptions.

Test Added.
  • Loading branch information...
markstory committed Aug 30, 2010
1 parent 534f600 commit 1f30c06695911ea10543140abe4667155d573aae
Showing with 25 additions and 1 deletion.
  1. +1 −1 cake/libs/error_handler.php
  2. +24 −0 cake/tests/cases/libs/error_handler.test.php
@@ -179,7 +179,7 @@ protected function _cakeError(CakeException $error) {
*/
public function error404($error) {
$message = $error->getMessage();
if (Configure::read('debug') == 0) {
if (Configure::read('debug') == 0 && $error instanceof CakeException) {
$message = __('Not Found');
}
$url = Router::normalize($this->controller->request->here);
@@ -376,6 +376,30 @@ function testError404() {
App::build();
}
/**
* test that error404 only modifies the messages on CakeExceptions.
*
* @return void
*/
function testError404OnlyChangingCakeException() {
Configure::write('debug', 0);
$exception = new Error404Exception('Custom message');
$ErrorHandler = new ErrorHandler($exception);
ob_start();
$ErrorHandler->render();
$result = ob_get_clean();
$this->assertContains('Custom message', $result);
$exception = new MissingActionException(array('controller' => 'PostsController', 'action' => 'index'));
$ErrorHandler = new ErrorHandler($exception);
ob_start();
$ErrorHandler->render();
$result = ob_get_clean();
$this->assertContains('Not Found', $result);
}
/**
* test that error404 doesn't expose XSS
*

0 comments on commit 1f30c06

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