Fixing issue in error handler, where URL was not escaped with debug == 0.

Tests added.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8028 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mark_story 2009-02-13 14:56:00 +00:00
parent 2a36e5f8cd
commit fdd6ad856e
2 changed files with 14 additions and 2 deletions

View file

@ -151,7 +151,7 @@ class ErrorHandler extends Object {
$this->controller->set(array( $this->controller->set(array(
'code' => '404', 'code' => '404',
'name' => __('Not Found', true), 'name' => __('Not Found', true),
'message' => $url, 'message' => h($url),
'base' => $this->controller->base 'base' => $this->controller->base
)); ));
$this->_outputMessage('error404'); $this->_outputMessage('error404');

View file

@ -259,6 +259,18 @@ class TestErrorHandlerTest extends CakeTestCase {
$result = ob_get_clean(); $result = ob_get_clean();
$this->assertPattern('/<h2>Not Found<\/h2>/', $result); $this->assertPattern('/<h2>Not Found<\/h2>/', $result);
$this->assertPattern("/<strong>'\/test_error'<\/strong>/", $result); $this->assertPattern("/<strong>'\/test_error'<\/strong>/", $result);
ob_start();
$TestErrorHandler =& new TestErrorHandler('error404', array('message' => 'Page not found'));
ob_get_clean();
ob_start();
$TestErrorHandler->error404(array(
'url' => 'pages/<span id=333>pink</span></id><script>document.body.style.background = t=document.getElementById(333).innerHTML;window.alert(t);</script>',
'message' => 'Page not found'
));
$result = ob_get_clean();
$this->assertNoPattern('#<script>#', $result);
$this->assertNoPattern('#</script>#', $result);
} }
/** /**
* testMissingController method * testMissingController method