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
This commit is contained in:
joelmoss 2008-07-09 12:08:51 +00:00
parent 8d644172c9
commit aa1b0c776e
2 changed files with 4 additions and 1 deletions

View file

@ -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;

View file

@ -418,6 +418,9 @@ class JavascriptTest extends UnitTestCase {
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
$result = $this->Javascript->blockEnd();
$this->assertPattern('/^<\/script>$/', $result);
$result = $this->Javascript->codeBlock('something', array('safe' => true));
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*something\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
$this->assertPattern('/^<script[^<>]+type="text\/javascript">\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*something\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);