From 04301645d60b08a00c919536640586cf6a8c1573 Mon Sep 17 00:00:00 2001 From: uwetews Date: Fri, 5 Aug 2016 01:00:51 +0200 Subject: [PATCH] - bugfix compiling of templates failed when the Smarty delimiter did contain '/' https://github.com/smarty-php/smarty/issues/264 --- change_log.txt | 3 +++ lexer/smarty_internal_templatelexer.plex | 14 +++++++------- libs/Smarty.class.php | 2 +- libs/sysplugins/smarty_internal_templatelexer.php | 14 +++++++------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/change_log.txt b/change_log.txt index 93608c87..cc785ebc 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@  ===== 3.1.30-dev ===== (xx.xx.xx) + 05.08.2015 + - bugfix compiling of templates failed when the Smarty delimiter did contain '/' https://github.com/smarty-php/smarty/issues/264 + 04.08.2015 - improvement move template function source parameter into extension diff --git a/lexer/smarty_internal_templatelexer.plex b/lexer/smarty_internal_templatelexer.plex index 44ab67e6..312c6fd0 100644 --- a/lexer/smarty_internal_templatelexer.plex +++ b/lexer/smarty_internal_templatelexer.plex @@ -226,15 +226,15 @@ class Smarty_Internal_Templatelexer { $this->data = $data; $this->counter = 0; - if (preg_match('~^\xEF\xBB\xBF~i', $this->data, $match)) { + if (preg_match('/^\xEF\xBB\xBF/i', $this->data, $match)) { $this->counter += strlen($match[0]); } $this->line = 1; $this->smarty = $compiler->smarty; $this->compiler = $compiler; - $this->ldel = preg_quote($this->smarty->left_delimiter, '~'); + $this->ldel = preg_quote($this->smarty->left_delimiter, '/'); $this->ldel_length = strlen($this->smarty->left_delimiter); - $this->rdel = preg_quote($this->smarty->right_delimiter, '~'); + $this->rdel = preg_quote($this->smarty->right_delimiter, '/'); $this->rdel_length = strlen($this->smarty->right_delimiter); $this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter; $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter; @@ -331,7 +331,7 @@ class Smarty_Internal_Templatelexer $this->token = Smarty_Internal_Templateparser::TP_TEXT; } comment { - preg_match("~[*]{$this->rdel}~",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter); + preg_match("/[*]{$this->rdel}/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter); if (isset($match[0][1])) { $to = $match[0][1] + strlen($match[0][0]); } else { @@ -369,7 +369,7 @@ class Smarty_Internal_Templatelexer } text { $to = strlen($this->data); - preg_match("~($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|()|([?][>])|([%][>])~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter); + preg_match("/($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|()|([?][>])|([%][>])/i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter); if (isset($match[0][1])) { $to = $match[0][1]; } @@ -540,7 +540,7 @@ class Smarty_Internal_Templatelexer attr { // resolve conflicts with shorttag and right_delimiter starting with '=' if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == $this->smarty->right_delimiter) { - preg_match("~\s+~",$this->value,$match); + preg_match("/\s+/",$this->value,$match); $this->value = $match[0]; $this->token = Smarty_Internal_Templateparser::TP_SPACE; } else { @@ -609,7 +609,7 @@ class Smarty_Internal_Templatelexer } text { $to = strlen($this->data); - preg_match("~{$this->ldel}[/]?literal{$this->rdel}~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter); + preg_match("/{$this->ldel}[\/]?literal{$this->rdel}/i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter); if (isset($match[0][1])) { $to = $match[0][1]; } else { diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index b0ecc0ba..2d9fc29d 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/89'; + const SMARTY_VERSION = '3.1.30-dev/90'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_templatelexer.php b/libs/sysplugins/smarty_internal_templatelexer.php index c0c8f7c5..fd9002b7 100644 --- a/libs/sysplugins/smarty_internal_templatelexer.php +++ b/libs/sysplugins/smarty_internal_templatelexer.php @@ -203,15 +203,15 @@ class Smarty_Internal_Templatelexer { $this->data = $data; $this->counter = 0; - if (preg_match('~^\xEF\xBB\xBF~i', $this->data, $match)) { + if (preg_match('/^\xEF\xBB\xBF/i', $this->data, $match)) { $this->counter += strlen($match[ 0 ]); } $this->line = 1; $this->smarty = $compiler->smarty; $this->compiler = $compiler; - $this->ldel = preg_quote($this->smarty->left_delimiter, '~'); + $this->ldel = preg_quote($this->smarty->left_delimiter, '/'); $this->ldel_length = strlen($this->smarty->left_delimiter); - $this->rdel = preg_quote($this->smarty->right_delimiter, '~'); + $this->rdel = preg_quote($this->smarty->right_delimiter, '/'); $this->rdel_length = strlen($this->smarty->right_delimiter); $this->smarty_token_names[ 'LDEL' ] = $this->smarty->left_delimiter; $this->smarty_token_names[ 'RDEL' ] = $this->smarty->right_delimiter; @@ -348,7 +348,7 @@ class Smarty_Internal_Templatelexer function yy_r1_2() { - preg_match("~[*]{$this->rdel}~", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); + preg_match("/[*]{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); if (isset($match[ 0 ][ 1 ])) { $to = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]); } else { @@ -408,7 +408,7 @@ class Smarty_Internal_Templatelexer { $to = strlen($this->data); - preg_match("~($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|()|([?][>])|([%][>])~i", + preg_match("/($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|()|([?][>])|([%][>])/i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); if (isset($match[ 0 ][ 1 ])) { $to = $match[ 0 ][ 1 ]; @@ -814,7 +814,7 @@ class Smarty_Internal_Templatelexer if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == $this->smarty->right_delimiter ) { - preg_match("~\s+~", $this->value, $match); + preg_match("/\s+/", $this->value, $match); $this->value = $match[ 0 ]; $this->token = Smarty_Internal_Templateparser::TP_SPACE; } else { @@ -985,7 +985,7 @@ class Smarty_Internal_Templatelexer { $to = strlen($this->data); - preg_match("~{$this->ldel}[/]?literal{$this->rdel}~i", $this->data, $match, PREG_OFFSET_CAPTURE, + preg_match("/{$this->ldel}[\/]?literal{$this->rdel}/i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); if (isset($match[ 0 ][ 1 ])) { $to = $match[ 0 ][ 1 ];