From ff7fce9bca548f694de9b9e30029318b89dcbe5c Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Tue, 20 Jul 2010 16:19:54 +0000 Subject: [PATCH] - fixed handling of { strip } tag with whitespaces --- change_log.txt | 3 + .../smarty_internal_templatelexer.php | 56 +++++++++++++------ 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/change_log.txt b/change_log.txt index a573e81f..768c0b4c 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +20/07/2010 +- fixed handling of { strip } tag with whitespaces + 15/07/2010 - bufix {$smarty.template} does include now the relative path, not just filename diff --git a/libs/sysplugins/smarty_internal_templatelexer.php b/libs/sysplugins/smarty_internal_templatelexer.php index cf377000..b2cb6350 100644 --- a/libs/sysplugins/smarty_internal_templatelexer.php +++ b/libs/sysplugins/smarty_internal_templatelexer.php @@ -143,19 +143,21 @@ class Smarty_Internal_Templatelexer 10 => 0, 11 => 0, 12 => 0, - 13 => 1, - 15 => 0, - 16 => 0, + 13 => 0, + 14 => 0, + 15 => 1, 17 => 0, 18 => 0, 19 => 0, - 20 => 2, - 23 => 0, + 20 => 0, + 21 => 0, + 22 => 2, + 25 => 0, ); if ($this->counter >= strlen($this->data)) { return false; // end of input } - $yy_global_pattern = "/^(\\{\\})|^(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel."\r?\n?)|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(<%)|^(%>)|^([\t ]*[\r\n]+[\t ]*)|^(".$this->ldel."strip".$this->rdel.")|^(".$this->ldel."\/strip".$this->rdel.")|^(".$this->ldel."literal".$this->rdel.")|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)(?![^\s]))|^(".$this->ldel."\\s*for(?![^\s]))|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."|<\\?|\\?>|<%|%>)))|^([\S\s]+)/"; + $yy_global_pattern = "/^(\\{\\})|^(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel."\r?\n?)|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(<%)|^(%>)|^([\t ]*[\r\n]+[\t ]*)|^(".$this->ldel."strip".$this->rdel.")|^(".$this->ldel."\\s{1,}strip\\s{1,}".$this->rdel.")|^(".$this->ldel."\/strip".$this->rdel.")|^(".$this->ldel."\\s{1,}\/strip\\s{1,}".$this->rdel.")|^(".$this->ldel."\\s*literal\\s*".$this->rdel.")|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)(?![^\s]))|^(".$this->ldel."\\s*for(?![^\s]))|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."|<\\?|\\?>|<%|%>)))|^([\S\s]+)/"; do { if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) { @@ -260,16 +262,36 @@ class Smarty_Internal_Templatelexer function yy_r1_10($yy_subpatterns) { + if ($this->smarty->auto_literal) { + $this->token = Smarty_Internal_Templateparser::TP_OTHER; + } else { + $this->strip = true; + return false; + } + } + function yy_r1_11($yy_subpatterns) + { + $this->strip = false; return false; } - function yy_r1_11($yy_subpatterns) + function yy_r1_12($yy_subpatterns) + { + + if ($this->smarty->auto_literal) { + $this->token = Smarty_Internal_Templateparser::TP_OTHER; + } else { + $this->strip = false; + return false; + } + } + function yy_r1_13($yy_subpatterns) { $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART; $this->yypushstate(self::LITERAL); } - function yy_r1_12($yy_subpatterns) + function yy_r1_14($yy_subpatterns) { if ($this->smarty->auto_literal) { @@ -280,7 +302,7 @@ class Smarty_Internal_Templatelexer $this->taglineno = $this->line; } } - function yy_r1_13($yy_subpatterns) + function yy_r1_15($yy_subpatterns) { if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') { @@ -291,7 +313,7 @@ class Smarty_Internal_Templatelexer $this->taglineno = $this->line; } } - function yy_r1_15($yy_subpatterns) + function yy_r1_17($yy_subpatterns) { if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') { @@ -302,7 +324,7 @@ class Smarty_Internal_Templatelexer $this->taglineno = $this->line; } } - function yy_r1_16($yy_subpatterns) + function yy_r1_18($yy_subpatterns) { if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') { @@ -313,7 +335,7 @@ class Smarty_Internal_Templatelexer $this->taglineno = $this->line; } } - function yy_r1_17($yy_subpatterns) + function yy_r1_19($yy_subpatterns) { if ($this->smarty->auto_literal) { @@ -324,26 +346,26 @@ class Smarty_Internal_Templatelexer $this->taglineno = $this->line; } } - function yy_r1_18($yy_subpatterns) + function yy_r1_20($yy_subpatterns) { $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; $this->yypushstate(self::SMARTY); $this->taglineno = $this->line; } - function yy_r1_19($yy_subpatterns) + function yy_r1_21($yy_subpatterns) { $this->token = Smarty_Internal_Templateparser::TP_LDEL; $this->yypushstate(self::SMARTY); $this->taglineno = $this->line; } - function yy_r1_20($yy_subpatterns) + function yy_r1_22($yy_subpatterns) { $this->token = Smarty_Internal_Templateparser::TP_OTHER; } - function yy_r1_23($yy_subpatterns) + function yy_r1_25($yy_subpatterns) { $this->token = Smarty_Internal_Templateparser::TP_OTHER; @@ -870,7 +892,7 @@ class Smarty_Internal_Templatelexer if ($this->counter >= strlen($this->data)) { return false; // end of input } - $yy_global_pattern = "/^(".$this->ldel."literal".$this->rdel.")|^(".$this->ldel."\/literal".$this->rdel.")|^([\t ]*[\r\n]+[\t ]*)|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(<%)|^(%>)|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."\/?literal".$this->rdel."|<\\?|<%)))|^([\S\s]+)/"; + $yy_global_pattern = "/^(".$this->ldel."\\s*literal\\s*".$this->rdel.")|^(".$this->ldel."\\s*\/literal\\s*".$this->rdel.")|^([\t ]*[\r\n]+[\t ]*)|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(<%)|^(%>)|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."\/?literal".$this->rdel."|<\\?|<%)))|^([\S\s]+)/"; do { if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {