From 7887c37347a1dae4e973c02fa1e9b78a9cc20b10 Mon Sep 17 00:00:00 2001 From: artemsuv Date: Tue, 28 Aug 2018 14:12:23 +0300 Subject: [PATCH] Qoute special chars in custom delimiters and literals Using special chars in custom delimiters and literals cause " Warning preg_match(): Unknown modifier ']' " --- libs/sysplugins/smarty_internal_templatecompilerbase.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index 0ebc05b3c..a930ed28b 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -1147,20 +1147,20 @@ public function initDelimiterPreg() $this->ldelLength = strlen($ldel); $this->ldelPreg = ''; foreach (str_split($ldel, 1) as $chr) { - $this->ldelPreg .= '[' . ($chr === '\\' ? '\\' : '') . $chr . ']'; + $this->ldelPreg .= '[' . preg_quote($chr,'/') . ']'; } $rdel = $this->smarty->getRightDelimiter(); $this->rdelLength = strlen($rdel); $this->rdelPreg = ''; foreach (str_split($rdel, 1) as $chr) { - $this->rdelPreg .= '[' . ($chr === '\\' ? '\\' : '') . $chr . ']'; + $this->rdelPreg .= '[' . preg_quote($chr,'/') . ']'; } $literals = $this->smarty->getLiterals(); if (!empty($literals)) { foreach ($literals as $key => $literal) { $literalPreg = ''; foreach (str_split($literal, 1) as $chr) { - $literalPreg .= '[' . ($chr === '\\' ? '\\' : '') . $chr . ']'; + $literalPreg .= '[' . preg_quote($chr,'/') . ']'; } $literals[ $key ] = $literalPreg; }