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
This commit is contained in:
taggon 2011-10-11 00:33:03 +00:00
parent 82f117e32b
commit c105bbbfa2
2 changed files with 10 additions and 3 deletions

View file

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

View file

@ -117,7 +117,7 @@ class TemplateHandlerTest extends PHPUnit_Framework_TestCase
// <load target="style.css">
array(
'<dummy /><load target="css/style.css" /><dummy />',
'<dummy /><!--#Meta:tests/classes/template/css/style.css--><?php $__tmp=array(\'tests/classes/template/css/style.css\',\'\',\'\',\'\',\'\',\'\',\'\');Context::loadFile($__tmp);unset($__tmp); ?><dummy />'
'<dummy /><!--#Meta:tests/classes/template/css/style.css--><?php $__tmp=array(\'tests/classes/template/css/style.css\',\'\',\'\',\'\');Context::loadFile($__tmp,\'\',\'\',\'\');unset($__tmp); ?><dummy />'
),
// <unload target="style.css">
array(
@ -132,7 +132,7 @@ class TemplateHandlerTest extends PHPUnit_Framework_TestCase
// <!--%import("../script.js",type="body")-->
array(
'<dummy /><!--%import("../script.js",type="body")--><dummy />',
'<dummy /><!--#Meta:tests/classes/script.js--><?php $__tmp=array(\'tests/classes/script.js\',\'body\',\'\',\'\',\'\',\'\',\'\');Context::loadFile($__tmp);unset($__tmp); ?><dummy />'
'<dummy /><!--#Meta:tests/classes/script.js--><?php $__tmp=array(\'tests/classes/script.js\',\'body\',\'\',\'\');Context::loadFile($__tmp,\'\',\'\',\'\');unset($__tmp); ?><dummy />'
),
// <!--%unload("../script.js",type="body")-->
array(
@ -174,10 +174,15 @@ class TemplateHandlerTest extends PHPUnit_Framework_TestCase
'<script type="text/javascript">var json = {hello:"world"};</script>',
'<script type="text/javascript">var json = {hello:"world"};</script>'
),
// error case - inline javascript
array(
'<form onsubmit="jQuery(this).find(\'input\').each(function(){if(this.title==this.value)this.value=\'\';}); return procFilter(this, insert_comment)"></form>',
'<form onsubmit="jQuery(this).find(\'input\').each(function(){if(this.title==this.value)this.value=\'\';}); return procFilter(this, insert_comment)"><input type="hidden" name="error_return_url" value="<?php echo getRequestUriByServerEnviroment() ?>" /><input type="hidden" name="act" value="<?php echo $act ?>"><input type="hidden" name="mid" value="<?php echo $mid ?>"><input type="hidden" name="vid" value="<?php echo $vid ?>"></form>'
),
// issue 103
array(
'<load target="http://aaa.com/aaa.js" />',
'<!--#Meta:http://aaa.com/aaa.js--><?php $__tmp=array(\'http://aaa.com/aaa.js\',\'\',\'\',\'\',\'\',\'\',\'\');Context::loadFile($__tmp);unset($__tmp); ?>'
'<!--#Meta:http://aaa.com/aaa.js--><?php $__tmp=array(\'http://aaa.com/aaa.js\',\'\',\'\',\'\');Context::loadFile($__tmp,\'\',\'\',\'\');unset($__tmp); ?>'
),
// issue 135
array(