From c105bbbfa2f25cceb6d0c485f171f8dccbc32a21 Mon Sep 17 00:00:00 2001 From: taggon Date: Tue, 11 Oct 2011 00:33:03 +0000 Subject: [PATCH] Fixed a tempalte bug that the engine parses javascript code blocks as php echo syntax git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9547 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/template/TemplateHandler.class.php | 2 ++ tests/classes/template/TemplateHandlerTest.class.php | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index 3c2793aad..fa48f192a 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -379,6 +379,8 @@ // {@ ... } or {$var} or {func(...)} if($m[1]) { + if(preg_match('@^(\w+)\(@', $m[1], $mm) && !function_exists($mm[1])) return $m[0]; + $echo = 'echo '; if($m[1]{0} == '@') { $echo = ''; diff --git a/tests/classes/template/TemplateHandlerTest.class.php b/tests/classes/template/TemplateHandlerTest.class.php index af7b9e0d6..0497468cd 100644 --- a/tests/classes/template/TemplateHandlerTest.class.php +++ b/tests/classes/template/TemplateHandlerTest.class.php @@ -117,7 +117,7 @@ class TemplateHandlerTest extends PHPUnit_Framework_TestCase // array( '', - '' + '' ), // array( @@ -132,7 +132,7 @@ class TemplateHandlerTest extends PHPUnit_Framework_TestCase // array( '', - '' + '' ), // array( @@ -174,10 +174,15 @@ class TemplateHandlerTest extends PHPUnit_Framework_TestCase '', '' ), + // error case - inline javascript + array( + '
', + '
' + ), // issue 103 array( '', - '' + '' ), // issue 135 array(