mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- bugfix {if $foo instanceof $bar} failed to compile if 2nd value is a variable https://github.com/smarty-php/smarty/issues/92
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
===== 3.1.28-dev===== (xx.xx.2015)
|
===== 3.1.28-dev===== (xx.xx.2015)
|
||||||
|
18.09.2015
|
||||||
|
- bugfix {if $foo instanceof $bar} failed to compile if 2nd value is a variable https://github.com/smarty-php/smarty/issues/92
|
||||||
|
|
||||||
17.09.2015
|
17.09.2015
|
||||||
- bugfix {foreach} first attribute was not correctly reset since commit 05a8fa2 of 02.08.2015 https://github.com/smarty-php/smarty/issues/90
|
- bugfix {foreach} first attribute was not correctly reset since commit 05a8fa2 of 02.08.2015 https://github.com/smarty-php/smarty/issues/90
|
||||||
|
|
||||||
|
@@ -697,6 +697,10 @@ expr(res) ::= variable(v1) INSTANCEOF(i) ns1(v2). {
|
|||||||
res = v1.i.v2;
|
res = v1.i.v2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expr(res) ::= variable(v1) INSTANCEOF(i) variable(v2). {
|
||||||
|
res = v1.i.v2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// ternary
|
// ternary
|
||||||
|
@@ -119,7 +119,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '3.1.28-dev/62';
|
const SMARTY_VERSION = '3.1.28-dev/63';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
|
@@ -229,8 +229,8 @@ class Smarty_Internal_Templatelexer
|
|||||||
*/
|
*/
|
||||||
public function isAutoLiteral()
|
public function isAutoLiteral()
|
||||||
{
|
{
|
||||||
return $this->smarty->auto_literal &&
|
return $this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ?
|
||||||
isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false;
|
strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private $_yy_state = 1;
|
private $_yy_state = 1;
|
||||||
@@ -245,23 +245,31 @@ class Smarty_Internal_Templatelexer
|
|||||||
public function yypushstate($state)
|
public function yypushstate($state)
|
||||||
{
|
{
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt,
|
||||||
|
isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] :
|
||||||
|
$this->_yy_state);
|
||||||
}
|
}
|
||||||
array_push($this->_yy_stack, $this->_yy_state);
|
array_push($this->_yy_stack, $this->_yy_state);
|
||||||
$this->_yy_state = $state;
|
$this->_yy_state = $state;
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt,
|
||||||
|
isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] :
|
||||||
|
$this->_yy_state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function yypopstate()
|
public function yypopstate()
|
||||||
{
|
{
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt,
|
||||||
|
isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] :
|
||||||
|
$this->_yy_state);
|
||||||
}
|
}
|
||||||
$this->_yy_state = array_pop($this->_yy_stack);
|
$this->_yy_state = array_pop($this->_yy_stack);
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt,
|
||||||
|
isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] :
|
||||||
|
$this->_yy_state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,16 +277,19 @@ class Smarty_Internal_Templatelexer
|
|||||||
{
|
{
|
||||||
$this->_yy_state = $state;
|
$this->_yy_state = $state;
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt,
|
||||||
|
isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] :
|
||||||
|
$this->_yy_state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function yylex1()
|
public function yylex1()
|
||||||
{
|
{
|
||||||
if (!isset($this->yy_global_pattern1)) {
|
if (!isset($this->yy_global_pattern1)) {
|
||||||
$this->yy_global_pattern1 = "/\G([{][}])|\G(" . $this->ldel . "[*])|\G((" . $this->ldel . "\\s*php(.*?)" .
|
$this->yy_global_pattern1 =
|
||||||
$this->rdel . ")|(" . $this->ldel . "\\s*[\/]php" . $this->rdel . "))|\G(" . $this->ldel .
|
"/\G([{][}])|\G(" . $this->ldel . "[*])|\G((" . $this->ldel . "\\s*php(.*?)" . $this->rdel . ")|(" .
|
||||||
"\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel .
|
$this->ldel . "\\s*[\/]php" . $this->rdel . "))|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel .
|
||||||
|
")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel .
|
||||||
")|\G((<[?]((php\\s+|=)|\\s+))|(<[%])|(<[?]xml\\s+)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|([?][>])|([%][>]))|\G([\S\s])/isS";
|
")|\G((<[?]((php\\s+|=)|\\s+))|(<[%])|(<[?]xml\\s+)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|([?][>])|([%][>]))|\G([\S\s])/isS";
|
||||||
}
|
}
|
||||||
if ($this->counter >= strlen($this->data)) {
|
if ($this->counter >= strlen($this->data)) {
|
||||||
@@ -357,8 +368,8 @@ class Smarty_Internal_Templatelexer
|
|||||||
function yy_r1_7()
|
function yy_r1_7()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->smarty->auto_literal &&
|
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ?
|
||||||
isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false
|
strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false
|
||||||
) {
|
) {
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||||
} else {
|
} else {
|
||||||
@@ -370,8 +381,8 @@ class Smarty_Internal_Templatelexer
|
|||||||
function yy_r1_8()
|
function yy_r1_8()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->smarty->auto_literal &&
|
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ?
|
||||||
isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false
|
strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false
|
||||||
) {
|
) {
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||||
} else {
|
} else {
|
||||||
@@ -397,7 +408,8 @@ class Smarty_Internal_Templatelexer
|
|||||||
{
|
{
|
||||||
|
|
||||||
$to = strlen($this->data);
|
$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])) {
|
if (isset($match[0][1])) {
|
||||||
$to = $match[0][1];
|
$to = $match[0][1];
|
||||||
}
|
}
|
||||||
@@ -408,12 +420,13 @@ class Smarty_Internal_Templatelexer
|
|||||||
public function yylex2()
|
public function yylex2()
|
||||||
{
|
{
|
||||||
if (!isset($this->yy_global_pattern2)) {
|
if (!isset($this->yy_global_pattern2)) {
|
||||||
$this->yy_global_pattern2 = "/\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel .
|
$this->yy_global_pattern2 =
|
||||||
"\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel .
|
"/\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" .
|
||||||
"\\s*setfilter\\s+)|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel .
|
$this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G(" . $this->ldel .
|
||||||
")|\G(" . $this->ldel . "\\s*[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*" . $this->rdel . ")|\G(" .
|
"\\s*[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel .
|
||||||
$this->ldel . "\\s*[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel .
|
"\\s*[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*" . $this->rdel . ")|\G(" . $this->ldel .
|
||||||
"\\s*[\/])|\G(" . $this->ldel . "\\s*)/isS";
|
"\\s*[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" .
|
||||||
|
$this->ldel . "\\s*)/isS";
|
||||||
}
|
}
|
||||||
if ($this->counter >= strlen($this->data)) {
|
if ($this->counter >= strlen($this->data)) {
|
||||||
return false; // end of input
|
return false; // end of input
|
||||||
@@ -863,8 +876,8 @@ class Smarty_Internal_Templatelexer
|
|||||||
function yy_r3_64()
|
function yy_r3_64()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->smarty->auto_literal &&
|
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ?
|
||||||
isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false
|
strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false
|
||||||
) {
|
) {
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||||
} else {
|
} else {
|
||||||
@@ -882,8 +895,9 @@ class Smarty_Internal_Templatelexer
|
|||||||
public function yylex4()
|
public function yylex4()
|
||||||
{
|
{
|
||||||
if (!isset($this->yy_global_pattern4)) {
|
if (!isset($this->yy_global_pattern4)) {
|
||||||
$this->yy_global_pattern4 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel .
|
$this->yy_global_pattern4 =
|
||||||
"\\s*[\/]literal\\s*" . $this->rdel . ")|\G([\S\s])/isS";
|
"/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" .
|
||||||
|
$this->rdel . ")|\G([\S\s])/isS";
|
||||||
}
|
}
|
||||||
if ($this->counter >= strlen($this->data)) {
|
if ($this->counter >= strlen($this->data)) {
|
||||||
return false; // end of input
|
return false; // end of input
|
||||||
@@ -955,7 +969,8 @@ class Smarty_Internal_Templatelexer
|
|||||||
{
|
{
|
||||||
|
|
||||||
$to = strlen($this->data);
|
$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])) {
|
if (isset($match[0][1])) {
|
||||||
$to = $match[0][1];
|
$to = $match[0][1];
|
||||||
} else {
|
} else {
|
||||||
@@ -968,9 +983,10 @@ class Smarty_Internal_Templatelexer
|
|||||||
public function yylex5()
|
public function yylex5()
|
||||||
{
|
{
|
||||||
if (!isset($this->yy_global_pattern5)) {
|
if (!isset($this->yy_global_pattern5)) {
|
||||||
$this->yy_global_pattern5 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel .
|
$this->yy_global_pattern5 =
|
||||||
"\\s*[\/]literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel .
|
"/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" .
|
||||||
"\\s*[0-9]*[a-zA-Z_]\\w*)|\G(" . $this->ldel .
|
$this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*)|\G(" .
|
||||||
|
$this->ldel .
|
||||||
"\\s*)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" .
|
"\\s*)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" .
|
||||||
$this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/isS";
|
$this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/isS";
|
||||||
}
|
}
|
||||||
@@ -1036,8 +1052,8 @@ class Smarty_Internal_Templatelexer
|
|||||||
function yy_r5_3()
|
function yy_r5_3()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->smarty->auto_literal &&
|
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ?
|
||||||
isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false
|
strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false
|
||||||
) {
|
) {
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||||
} else {
|
} else {
|
||||||
@@ -1049,8 +1065,8 @@ class Smarty_Internal_Templatelexer
|
|||||||
function yy_r5_4()
|
function yy_r5_4()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->smarty->auto_literal &&
|
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ?
|
||||||
isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false
|
strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false
|
||||||
) {
|
) {
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||||
} else {
|
} else {
|
||||||
@@ -1062,8 +1078,8 @@ class Smarty_Internal_Templatelexer
|
|||||||
function yy_r5_5()
|
function yy_r5_5()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->smarty->auto_literal &&
|
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ?
|
||||||
isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false
|
strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false
|
||||||
) {
|
) {
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||||
} else {
|
} else {
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user