From 77292d394a98e844266b85bfa56a7bfe4b57947b Mon Sep 17 00:00:00 2001 From: "Uwe.Tews@googlemail.com" Date: Wed, 16 Jul 2014 18:21:25 +0000 Subject: [PATCH] - enhancement remove BOM automatically from template source (topic 25161) --- change_log.txt | 3 +++ libs/sysplugins/smarty_internal_configfilelexer.php | 3 +++ libs/sysplugins/smarty_internal_templatelexer.php | 3 +++ libs/sysplugins/smarty_internal_templateparser.php | 3 ++- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/change_log.txt b/change_log.txt index 6e7ae7d1..fc6703a9 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== 3.1.20-dev ===== (xx.xx.2014) + 16.07.2014 + - enhancement remove BOM automatically from template source (topic 25161) + 04.07.2014 - bugfix the bufix of 02.06.2014 broke correct handling of child templates with same name but different template folders in extends resource (issue 194 and topic 25099) diff --git a/libs/sysplugins/smarty_internal_configfilelexer.php b/libs/sysplugins/smarty_internal_configfilelexer.php index e5019773..d5b50775 100644 --- a/libs/sysplugins/smarty_internal_configfilelexer.php +++ b/libs/sysplugins/smarty_internal_configfilelexer.php @@ -33,6 +33,9 @@ class Smarty_Internal_Configfilelexer self::instance($this); $this->data = $data . "\n"; //now all lines are \n-terminated $this->counter = 0; + if (preg_match('/\xEF\xBB\xBF/', $this->data, $match)) { + $this->counter += strlen($match[0]); + } $this->line = 1; $this->compiler = $compiler; $this->smarty = $compiler->smarty; diff --git a/libs/sysplugins/smarty_internal_templatelexer.php b/libs/sysplugins/smarty_internal_templatelexer.php index a94b5f1e..45583d9b 100644 --- a/libs/sysplugins/smarty_internal_templatelexer.php +++ b/libs/sysplugins/smarty_internal_templatelexer.php @@ -82,6 +82,9 @@ class Smarty_Internal_Templatelexer // $this->data = preg_replace("/(\r\n|\r|\n)/", "\n", $data); $this->data = $data; $this->counter = 0; + if (preg_match('/\xEF\xBB\xBF/', $this->data, $match)) { + $this->counter += strlen($match[0]); + } $this->line = 1; $this->smarty = $compiler->smarty; $this->compiler = $compiler; diff --git a/libs/sysplugins/smarty_internal_templateparser.php b/libs/sysplugins/smarty_internal_templateparser.php index c781e4c1..d09f16c2 100644 --- a/libs/sysplugins/smarty_internal_templateparser.php +++ b/libs/sysplugins/smarty_internal_templateparser.php @@ -2662,7 +2662,8 @@ class Smarty_Internal_Templateparser #line 80 "smarty_internal_templateparser.ph if (isset(self::$yyExpectedTokens[$nextstate])) { $expected = array_merge($expected, self::$yyExpectedTokens[$nextstate]); if (in_array($token, - self::$yyExpectedTokens[$nextstate], true)) { + self::$yyExpectedTokens[$nextstate], true) + ) { $this->yyidx = $yyidx; $this->yystack = $stack;