- bugfix compiling of templates failed when the Smarty delimiter did contain '/' https://github.com/smarty-php/smarty/issues/264

This commit is contained in:
uwetews
2016-08-05 01:00:51 +02:00
parent e96a218e8b
commit 04301645d6
4 changed files with 18 additions and 15 deletions

View File

@@ -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

View File

@@ -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+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\s*>)|([?][>])|([%][>])~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
preg_match("/($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\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 {

View File

@@ -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

View File

@@ -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+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\s*>)|([?][>])|([%][>])~i",
preg_match("/($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\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 ];