From aa1b0c776e176da6977017fb6bcc21207ff97d02 Mon Sep 17 00:00:00 2001 From: joelmoss Date: Wed, 9 Jul 2008 12:08:51 +0000 Subject: [PATCH] JavascriptHelper::blockEnd now correctly respects safe option. Test also added. Fixes #5074 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7330 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/view/helpers/javascript.php | 2 +- cake/tests/cases/libs/view/helpers/javascript.test.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cake/libs/view/helpers/javascript.php b/cake/libs/view/helpers/javascript.php index 9a2c3ba4a..e82e92b73 100644 --- a/cake/libs/view/helpers/javascript.php +++ b/cake/libs/view/helpers/javascript.php @@ -217,7 +217,7 @@ class JavascriptHelper extends AppHelper { echo $this->__scriptBuffer; $this->__scriptBuffer = null; $options = $this->_blockOptions; - $safe = (isset($options['safe']) || $this->safe); + $safe = ((isset($options['safe']) && $options['safe']) || $this->safe); $this->_blockOptions = array(); $this->inBlock = false; diff --git a/cake/tests/cases/libs/view/helpers/javascript.test.php b/cake/tests/cases/libs/view/helpers/javascript.test.php index 91ab9efbb..c9d59b891 100644 --- a/cake/tests/cases/libs/view/helpers/javascript.test.php +++ b/cake/tests/cases/libs/view/helpers/javascript.test.php @@ -418,6 +418,9 @@ class JavascriptTest extends UnitTestCase { $this->assertPattern('/^]+type="text\/javascript"[^<>]*>/', $result); $this->assertNoPattern('/^]*>/', $result); + $result = $this->Javascript->blockEnd(); + $this->assertPattern('/^<\/script>$/', $result); + $result = $this->Javascript->codeBlock('something', array('safe' => true)); $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/^]+type="text\/javascript">\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result);