From 9c37394ccbc63c5f265c0484a23364d963efc5c5 Mon Sep 17 00:00:00 2001 From: uwetews Date: Wed, 10 Feb 2016 21:12:35 +0100 Subject: [PATCH] - bugfix other {strip} error with output tags between hmtl https://github.com/smarty-php/smarty/issues/180 --- change_log.txt | 3 ++- libs/Smarty.class.php | 2 +- libs/sysplugins/smarty_internal_templatecompilerbase.php | 6 ++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/change_log.txt b/change_log.txt index c1dfe7ee0..95a5b4ff8 100644 --- a/change_log.txt +++ b/change_log.txt @@ -3,7 +3,8 @@ - bugfix {strip} must keep space on output creating smarty tags within html tags https://github.com/smarty-php/smarty/issues/177 - bugfix wrong precedence on special if conditions like '$foo is ... by $bar' could cause wrong code https://github.com/smarty-php/smarty/issues/178 - improvement because of ambiguities the inline constant support has been removed from the $foo.bar syntax https://github.com/smarty-php/smarty/issues/149 - + - bugfix other {strip} error with output tags between hmtl https://github.com/smarty-php/smarty/issues/180 + 09.02.2016 - move some code from parser into compiler - reformat all code for unique style diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 68bd57ec6..047f7d63a 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -121,7 +121,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.30-dev/37'; + const SMARTY_VERSION = '3.1.30-dev/38'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index 031893cd5..dac39fea6 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -794,7 +794,6 @@ public function processText($text) if ((string) $text != '') { $store = array(); $_store = 0; - $space = ''; if ($this->parser->strip) { if (strpos($text, '<') !== false) { // capture html elements not to be messed with @@ -817,7 +816,7 @@ public function processText($text) '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1\2', // remove spaces between attributes (but not in attribute values!) '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', - '#^\s+<#Ss' => '<', '#>\s+$#Ss' => '>', $this->stripRegEx => '',); + '#^\s+<#Ss' => $this->has_output ? ' <' : '<', '#>[\040\011]+$#Ss' => '> ', '#>[\040\011]*[\n]\s*$#Ss' => '>', $this->stripRegEx => '',); $text = preg_replace(array_keys($expressions), array_values($expressions), $text); $_offset = 0; @@ -832,13 +831,12 @@ public function processText($text) $_store ++; } } - $space = $this->has_output && !preg_match('/^\s/', $text) ? ' ' : ''; } else { $text = preg_replace($this->stripRegEx, '', $text); } } $this->has_output = false; - return new Smarty_Internal_ParseTree_Text($space . $text); + return new Smarty_Internal_ParseTree_Text($text); } return null; }