From 96fd914cc1626d1da26471a047d823c8b5d1ebc2 Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Mon, 20 Nov 2017 04:07:51 +0100 Subject: [PATCH] bugfix rework of newline spacing between tag code and template text. now again identical with Smarty2 (forum topic 26878) --- change_log.txt | 4 ++++ lexer/smarty_internal_templatelexer.plex | 2 +- libs/Smarty.class.php | 4 ++-- .../variablefilter.htmlspecialchars.php | 6 +++--- .../smarty_internal_compile_assign.php | 4 ++-- .../smarty_internal_compile_block.php | 2 -- .../smarty_internal_compile_extends.php | 2 +- .../sysplugins/smarty_internal_compile_for.php | 2 +- .../smarty_internal_compile_foreach.php | 6 +++--- .../smarty_internal_compile_function.php | 4 ++-- .../smarty_internal_compile_include.php | 6 +++--- .../smarty_internal_compile_insert.php | 2 -- .../smarty_internal_compile_ldelim.php | 5 +---- .../smarty_internal_compile_make_nocache.php | 1 - ...y_internal_compile_private_block_plugin.php | 6 ++---- ...nternal_compile_private_function_plugin.php | 2 -- ...nternal_compile_private_object_function.php | 6 ------ ...ternal_compile_private_print_expression.php | 4 +--- ...nal_compile_private_registered_function.php | 2 -- .../smarty_internal_compile_rdelim.php | 10 ++-------- .../smarty_internal_extension_handler.php | 17 +++++++++-------- .../smarty_internal_runtime_codeframe.php | 2 +- libs/sysplugins/smarty_internal_template.php | 1 + .../smarty_internal_templatecompilerbase.php | 18 ++++-------------- .../smarty_internal_templatelexer.php | 6 +++++- .../smarty_internal_templateparser.php | 3 --- 26 files changed, 48 insertions(+), 79 deletions(-) diff --git a/change_log.txt b/change_log.txt index b753787d..a158cf09 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,8 @@ ===== 3.1.32 - dev === +20.11.2017 + - bugfix rework of newline spacing between tag code and template text. + now again identical with Smarty2 (forum topic 26878) + 05.11.2017 - lexer/parser optimization - code cleanup and optimizations diff --git a/lexer/smarty_internal_templatelexer.plex b/lexer/smarty_internal_templatelexer.plex index fb185db1..5908eaa6 100644 --- a/lexer/smarty_internal_templatelexer.plex +++ b/lexer/smarty_internal_templatelexer.plex @@ -340,7 +340,7 @@ class Smarty_Internal_Templatelexer $this->token = Smarty_Internal_Templateparser::TP_TEXT; } comment { - preg_match("/[*]{$this->compiler->getRdelPreg()}/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter); + preg_match("/[*]{$this->compiler->getRdelPreg()}[\n]?/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter); if (isset($match[0][1])) { $to = $match[0][1] + strlen($match[0][0]); } else { diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 54a5c39e..67d495a5 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.32-dev-35'; + const SMARTY_VERSION = '3.1.32-dev-36'; /** * define variable scopes */ @@ -921,7 +921,7 @@ class Smarty extends Smarty_Internal_TemplateBase * @param object $parent next higher level of Smarty variables * @param boolean $do_clone flag is Smarty object shall be cloned * - * @return object template object + * @return \Smarty_Internal_Template template object * @throws \SmartyException */ public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true) diff --git a/libs/plugins/variablefilter.htmlspecialchars.php b/libs/plugins/variablefilter.htmlspecialchars.php index aecd1e7e..3c85295d 100644 --- a/libs/plugins/variablefilter.htmlspecialchars.php +++ b/libs/plugins/variablefilter.htmlspecialchars.php @@ -5,15 +5,15 @@ * @package Smarty * @subpackage PluginsFilter */ - /** * Smarty htmlspecialchars variablefilter plugin * - * @param string $source input string + * @param string $source input string + * @param \Smarty_Internal_Template $template * * @return string filtered output */ -function smarty_variablefilter_htmlspecialchars($source) +function smarty_variablefilter_htmlspecialchars($source, Smarty_Internal_Template $template) { return htmlspecialchars($source, ENT_QUOTES, Smarty::$_CHARSET); } diff --git a/libs/sysplugins/smarty_internal_compile_assign.php b/libs/sysplugins/smarty_internal_compile_assign.php index 5ec7a183..cb2ea425 100644 --- a/libs/sysplugins/smarty_internal_compile_assign.php +++ b/libs/sysplugins/smarty_internal_compile_assign.php @@ -85,9 +85,9 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase $output .= "settype(\$_tmp_array, 'array');\n"; $output .= "}\n"; $output .= "\$_tmp_array{$parameter['smarty_internal_index']} = {$_attr['value']};\n"; - $output .= "\$_smarty_tpl->_assignInScope({$_var}, \$_tmp_array{$_params});\n?>"; + $output .= "\$_smarty_tpl->_assignInScope({$_var}, \$_tmp_array{$_params});?>"; } else { - $output = "_assignInScope({$_var}, {$_attr['value']}{$_params});\n?>"; + $output = "_assignInScope({$_var}, {$_attr['value']}{$_params});?>"; } return $output; } diff --git a/libs/sysplugins/smarty_internal_compile_block.php b/libs/sysplugins/smarty_internal_compile_block.php index e54f4196..557c009c 100644 --- a/libs/sysplugins/smarty_internal_compile_block.php +++ b/libs/sysplugins/smarty_internal_compile_block.php @@ -123,7 +123,6 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher $compiler->trigger_template_error(" '\$smarty.block.{$name}' used outside {block} tags ", $compiler->parser->lex->taglineno); } - $compiler->has_code = true; $compiler->suppressNocacheProcessing = true; switch ($name) { case 'child': @@ -235,7 +234,6 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_ if ($compiler->_cache['blockNesting'] === 0) { unset($compiler->_cache['blockNesting']); } - $compiler->has_code = true; $compiler->suppressNocacheProcessing = true; return $output; } diff --git a/libs/sysplugins/smarty_internal_compile_extends.php b/libs/sysplugins/smarty_internal_compile_extends.php index 7617f3af..58416661 100644 --- a/libs/sysplugins/smarty_internal_compile_extends.php +++ b/libs/sysplugins/smarty_internal_compile_extends.php @@ -112,7 +112,7 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh 'inheritance->endChild($_smarty_tpl' . (isset($template) ? ", {$template}{$inlineUids}" : - '') . ");\n?>\n"); + '') . ");\n?>"); } /** diff --git a/libs/sysplugins/smarty_internal_compile_for.php b/libs/sysplugins/smarty_internal_compile_for.php index f899769b..79848e52 100644 --- a/libs/sysplugins/smarty_internal_compile_for.php +++ b/libs/sysplugins/smarty_internal_compile_for.php @@ -164,7 +164,7 @@ class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase if ($openTag !== 'forelse') { $output .= "}\n"; } - $output .= "?>\n"; + $output .= "?>"; return $output; } } diff --git a/libs/sysplugins/smarty_internal_compile_foreach.php b/libs/sysplugins/smarty_internal_compile_foreach.php index b6971a19..471e92c3 100644 --- a/libs/sysplugins/smarty_internal_compile_foreach.php +++ b/libs/sysplugins/smarty_internal_compile_foreach.php @@ -262,7 +262,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo */ public function compileRestore($levels) { - return "\$_smarty_tpl->smarty->ext->_foreach->restore(\$_smarty_tpl, {$levels});\n"; + return "\$_smarty_tpl->smarty->ext->_foreach->restore(\$_smarty_tpl, {$levels});"; } } @@ -293,7 +293,7 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase if ($restore === 2) { $output .= "{$itemVar} = {$local}saved;\n"; } - $output .= "}\n} else {\n?>\n"; + $output .= "}\n} else {\n?>"; return $output; } } @@ -337,7 +337,7 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase /* @var Smarty_Internal_Compile_Foreach $foreachCompiler */ $foreachCompiler = $compiler->getTagCompiler('foreach'); $output .= $foreachCompiler->compileRestore(1); - $output .= "?>\n"; + $output .= "?>"; return $output; } } diff --git a/libs/sysplugins/smarty_internal_compile_function.php b/libs/sysplugins/smarty_internal_compile_function.php index bcb1f8aa..9acaafe1 100644 --- a/libs/sysplugins/smarty_internal_compile_function.php +++ b/libs/sysplugins/smarty_internal_compile_function.php @@ -132,7 +132,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase $output = "compiled->has_nocache_code = true;\n"; $output .= $_paramsCode; @@ -164,7 +164,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase $output = " \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}?>"; $compiler->parser->current_buffer->append_subtree($compiler->parser, diff --git a/libs/sysplugins/smarty_internal_compile_include.php b/libs/sysplugins/smarty_internal_compile_include.php index f6d456cb..217fb8f8 100644 --- a/libs/sysplugins/smarty_internal_compile_include.php +++ b/libs/sysplugins/smarty_internal_compile_include.php @@ -239,7 +239,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase if ($update_compile_id) { $_output .= $compiler->makeNocacheCode("\$_smarty_tpl->compile_id = array_pop(\$_compile_id_save);\n"); } - $_output .= "?>\n"; + $_output .= "?>"; return $_output; } if ($call_nocache) { @@ -260,7 +260,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase if ($update_compile_id) { $_output .= "\$_smarty_tpl->compile_id = array_pop(\$_compile_id_save);\n"; } - $_output .= "?>\n"; + $_output .= "?>"; return $_output; } @@ -305,7 +305,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase // get compiled code $compiled_code = "compiled->unifunc} (\$_smarty_tpl) {\n"; + $compiled_code .= "function {$tpl->compiled->unifunc} (Smarty_Internal_Template \$_smarty_tpl) {\n"; $compiled_code .= "?>\n" . $tpl->compiler->compileTemplateSource($tpl, null, $compiler->parent_compiler); $compiled_code .= "\n"; diff --git a/libs/sysplugins/smarty_internal_compile_insert.php b/libs/sysplugins/smarty_internal_compile_insert.php index bac0c801..e71abdce 100644 --- a/libs/sysplugins/smarty_internal_compile_insert.php +++ b/libs/sysplugins/smarty_internal_compile_insert.php @@ -52,8 +52,6 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase { // check and get attributes $_attr = $this->getAttributes($compiler, $args); - //Does tag create output - $compiler->has_output = isset($_attr[ 'assign' ]) ? false : true; $nocacheParam = $compiler->template->caching && ($compiler->tag_nocache || $compiler->nocache); if (!$nocacheParam) { // do not compile as nocache code diff --git a/libs/sysplugins/smarty_internal_compile_ldelim.php b/libs/sysplugins/smarty_internal_compile_ldelim.php index 7251dcd6..c22e1a63 100644 --- a/libs/sysplugins/smarty_internal_compile_ldelim.php +++ b/libs/sysplugins/smarty_internal_compile_ldelim.php @@ -16,7 +16,7 @@ */ class Smarty_Internal_Compile_Ldelim extends Smarty_Internal_CompileBase { - /** + /** * Compiles code for the {ldelim} tag * This tag does output the left delimiter * @@ -32,9 +32,6 @@ class Smarty_Internal_Compile_Ldelim extends Smarty_Internal_CompileBase if ($_attr[ 'nocache' ] === true) { $compiler->trigger_template_error('nocache option not allowed', null, true); } - // this tag does not return compiled code - $compiler->has_code = true; - return $compiler->smarty->left_delimiter; } } diff --git a/libs/sysplugins/smarty_internal_compile_make_nocache.php b/libs/sysplugins/smarty_internal_compile_make_nocache.php index 84225b5d..f793ecbb 100644 --- a/libs/sysplugins/smarty_internal_compile_make_nocache.php +++ b/libs/sysplugins/smarty_internal_compile_make_nocache.php @@ -52,7 +52,6 @@ class Smarty_Internal_Compile_Make_Nocache extends Smarty_Internal_CompileBase $_attr = $this->getAttributes($compiler, $args); if ($compiler->template->caching) { $output = "smarty->ext->_make_nocache->save(\$_smarty_tpl, {$_attr[ 'var' ]});\n?>\n"; - $compiler->has_code = true; $compiler->template->compiled->has_nocache_code = true; $compiler->suppressNocacheProcessing = true; return $output; diff --git a/libs/sysplugins/smarty_internal_compile_private_block_plugin.php b/libs/sysplugins/smarty_internal_compile_private_block_plugin.php index 7f8a379c..6c3f05aa 100644 --- a/libs/sysplugins/smarty_internal_compile_private_block_plugin.php +++ b/libs/sysplugins/smarty_internal_compile_private_block_plugin.php @@ -65,7 +65,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi $output .= "if (!is_callable({$callable})) {\nthrow new SmartyException('block tag \'{$tag}\' not callable or registered');\n}\n"; } $output .= "\$_smarty_tpl->smarty->_cache['_tag_stack'][] = array('{$tag}', {$_params});\n"; - $output .= "\$_block_repeat=true;\necho {$callback}({$_params}, null, \$_smarty_tpl, \$_block_repeat);\nwhile (\$_block_repeat) {\nob_start();\n?>"; + $output .= "\$_block_repeat=true;\necho {$callback}({$_params}, null, \$_smarty_tpl, \$_block_repeat);\nwhile (\$_block_repeat) {\nob_start();?>"; $this->openTag($compiler, $tag, array($_params, $compiler->nocache, $callback)); // maybe nocache because of nocache variables or nocache plugin $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; @@ -76,8 +76,6 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi } // closing tag of block plugin, restore nocache list($_params, $compiler->nocache, $callback) = $this->closeTag($compiler, substr($tag, 0, - 5)); - //Does tag create output - $compiler->has_output = isset($_params[ 'assign' ]) ? false : true; // compile code if (!isset($parameter[ 'modifier_list' ])) { $mod_pre = $mod_post = $mod_content = ''; @@ -93,7 +91,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi $output = "smarty->_cache[\'_tag_stack\']);?>'; } - return $output . "\n"; + return $output; } /** diff --git a/libs/sysplugins/smarty_internal_compile_private_function_plugin.php b/libs/sysplugins/smarty_internal_compile_private_function_plugin.php index a6b4b295..9e9c65f5 100644 --- a/libs/sysplugins/smarty_internal_compile_private_function_plugin.php +++ b/libs/sysplugins/smarty_internal_compile_private_function_plugin.php @@ -68,8 +68,6 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co array('modifierlist' => $parameter[ 'modifierlist' ], 'value' => $output)); } - //Does tag create output - $compiler->has_output = true; $output = "\n"; return $output; } diff --git a/libs/sysplugins/smarty_internal_compile_private_object_function.php b/libs/sysplugins/smarty_internal_compile_private_object_function.php index c10d1222..8d6c7e39 100644 --- a/libs/sysplugins/smarty_internal_compile_private_object_function.php +++ b/libs/sysplugins/smarty_internal_compile_private_object_function.php @@ -41,9 +41,6 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co { // check and get attributes $_attr = $this->getAttributes($compiler, $args); - //Does tag create output - $compiler->has_output = isset($_attr[ 'assign' ]) ? false : true; - unset($_attr[ 'nocache' ]); $_assign = null; if (isset($_attr[ 'assign' ])) { @@ -76,9 +73,6 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co $output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter[ 'modifierlist' ], 'value' => $output)); } - //Does tag create output - $compiler->has_output = isset($_attr[ 'assign' ]) ? false : true; - if (empty($_assign)) { return "\n"; } else { diff --git a/libs/sysplugins/smarty_internal_compile_private_print_expression.php b/libs/sysplugins/smarty_internal_compile_private_print_expression.php index 7e39a355..f1dc0938 100644 --- a/libs/sysplugins/smarty_internal_compile_private_print_expression.php +++ b/libs/sysplugins/smarty_internal_compile_private_print_expression.php @@ -120,9 +120,7 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C } } } - - $compiler->has_output = true; - $output = ""; + $output = "\n"; } return $output; diff --git a/libs/sysplugins/smarty_internal_compile_private_registered_function.php b/libs/sysplugins/smarty_internal_compile_private_registered_function.php index 14a04c3b..467f9a49 100644 --- a/libs/sysplugins/smarty_internal_compile_private_registered_function.php +++ b/libs/sysplugins/smarty_internal_compile_private_registered_function.php @@ -80,8 +80,6 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna array('modifierlist' => $parameter[ 'modifierlist' ], 'value' => $output)); } - //Does tag create output - $compiler->has_output = true; $output = "\n"; return $output; } diff --git a/libs/sysplugins/smarty_internal_compile_rdelim.php b/libs/sysplugins/smarty_internal_compile_rdelim.php index 2e6b43c1..e3d034da 100644 --- a/libs/sysplugins/smarty_internal_compile_rdelim.php +++ b/libs/sysplugins/smarty_internal_compile_rdelim.php @@ -14,7 +14,7 @@ * @package Smarty * @subpackage Compiler */ -class Smarty_Internal_Compile_Rdelim extends Smarty_Internal_CompileBase +class Smarty_Internal_Compile_Rdelim extends Smarty_Internal_Compile_Ldelim { /** * Compiles code for the {rdelim} tag @@ -28,13 +28,7 @@ class Smarty_Internal_Compile_Rdelim extends Smarty_Internal_CompileBase */ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) { - $_attr = $this->getAttributes($compiler, $args); - if ($_attr[ 'nocache' ] === true) { - $compiler->trigger_template_error('nocache option not allowed', null, true); - } - // this tag does not return compiled code - $compiler->has_code = true; - + parent::compile($args,$compiler); return $compiler->smarty->right_delimiter; } } diff --git a/libs/sysplugins/smarty_internal_extension_handler.php b/libs/sysplugins/smarty_internal_extension_handler.php index 4d7b04fa..90d3b81e 100644 --- a/libs/sysplugins/smarty_internal_extension_handler.php +++ b/libs/sysplugins/smarty_internal_extension_handler.php @@ -27,14 +27,15 @@ * Method extensions * @property Smarty_Internal_Method_GetTemplateVars $getTemplateVars * @property Smarty_Internal_Method_Append $append - * @property Smarty_Internal_Method_AppendByRef $appendByRef - * @property Smarty_Internal_Method_AssignGlobal $assignGlobal - * @property Smarty_Internal_Method_AssignByRef $assignByRef - * @property Smarty_Internal_Method_LoadFilter $loadFilter - * @property Smarty_Internal_Method_LoadPlugin $loadPlugin - * @property Smarty_Internal_Method_RegisterFilter $registerFilter - * @property Smarty_Internal_Method_RegisterObject $registerObject - * @property Smarty_Internal_Method_RegisterPlugin $registerPlugin + * @property Smarty_Internal_Method_AppendByRef $appendByRef + * @property Smarty_Internal_Method_AssignGlobal $assignGlobal + * @property Smarty_Internal_Method_AssignByRef $assignByRef + * @property Smarty_Internal_Method_LoadFilter $loadFilter + * @property Smarty_Internal_Method_LoadPlugin $loadPlugin + * @property Smarty_Internal_Method_RegisterFilter $registerFilter + * @property Smarty_Internal_Method_RegisterObject $registerObject + * @property Smarty_Internal_Method_RegisterPlugin $registerPlugin + * @property mixed|\Smarty_Template_Cached configLoad */ class Smarty_Internal_Extension_Handler { diff --git a/libs/sysplugins/smarty_internal_runtime_codeframe.php b/libs/sysplugins/smarty_internal_runtime_codeframe.php index 5dd560b2..1833c11a 100644 --- a/libs/sysplugins/smarty_internal_runtime_codeframe.php +++ b/libs/sysplugins/smarty_internal_runtime_codeframe.php @@ -88,7 +88,7 @@ class Smarty_Internal_Runtime_CodeFrame $output .= "?>/*/%%SmartyNocache:{$_template->compiled->nocache_hash}%%*/';\n"; } } - $output .= "?>\n"; + $output .= "?>"; $output .= $content; $output .= ""; $output .= $functions; diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index d26f7c7a..ae321725 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -17,6 +17,7 @@ * @property Smarty_Template_Compiled $compiled * @property Smarty_Template_Cached $cached * @property Smarty_Internal_TemplateCompilerBase $compiler + * @property mixed|\Smarty_Template_Cached registered_plugins * * The following methods will be dynamically loaded by the extension handler when they are called. * They are located in a corresponding Smarty_Internal_Method_xxxx class diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index 5ca53662..ed2edf97 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -225,12 +225,7 @@ abstract class Smarty_Internal_TemplateCompilerBase * @var bool */ public $has_variable_string = false; - /** - * Tag creates output - * - * @var bool - */ - public $has_output = false; + /** * Stack for {setfilter} {/setfilter} * @@ -833,9 +828,9 @@ abstract class Smarty_Internal_TemplateCompilerBase */ public function appendCode($left, $right) { - if (preg_match('/\s*\?>\s*$/', $left) && preg_match('/^\s*<\?php\s+/', $right)) { - $left = preg_replace('/\s*\?>\s*$/', "\n", $left); - $left .= preg_replace('/^\s*<\?php\s+/', '', $right); + if (preg_match('/\s*\?>\s?$/D', $left) && preg_match('/^<\?php\s+/', $right)) { + $left = preg_replace('/\s*\?>\s?$/D', "\n", $left); + $left .= preg_replace('/^<\?php\s+/', '', $right); } else { $left .= $right; } @@ -1298,7 +1293,6 @@ abstract class Smarty_Internal_TemplateCompilerBase // $args contains the attributes parsed and compiled by the lexer/parser // assume that tag does compile into code, but creates no HTML output $this->has_code = true; - $this->has_output = false; // log tag/attributes if (isset($this->smarty->_cache[ 'get_used_tags' ])) { $this->template->_cache[ 'used_tags' ][] = array($tag, @@ -1333,10 +1327,6 @@ abstract class Smarty_Internal_TemplateCompilerBase if ($_output !== true) { // did we get compiled code if ($this->has_code) { - // Does it create output? - if ($this->has_output) { - $_output .= "\n"; - } // return compiled code return $_output; } diff --git a/libs/sysplugins/smarty_internal_templatelexer.php b/libs/sysplugins/smarty_internal_templatelexer.php index 02587c43..c097f44b 100644 --- a/libs/sysplugins/smarty_internal_templatelexer.php +++ b/libs/sysplugins/smarty_internal_templatelexer.php @@ -368,7 +368,11 @@ class Smarty_Internal_Templatelexer function yy_r1_2() { - preg_match("/[*]{$this->compiler->getRdelPreg()}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); + preg_match("/[*]{$this->compiler->getRdelPreg()}[\n]?/", + $this->data, + $match, + PREG_OFFSET_CAPTURE, + $this->counter); if (isset($match[ 0 ][ 1 ])) { $to = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]); } else { diff --git a/libs/sysplugins/smarty_internal_templateparser.php b/libs/sysplugins/smarty_internal_templateparser.php index 66d72b5e..4a10f56b 100644 --- a/libs/sysplugins/smarty_internal_templateparser.php +++ b/libs/sysplugins/smarty_internal_templateparser.php @@ -9,9 +9,6 @@ class TP_yyStackEntry ** is the value of the token */ } -; -#line 11 "../smarty/lexer/smarty_internal_templateparser.y" - /** * Smarty Template Parser Class *