- bugfix using {$foo} as array index like $bar.{$foo} or in double quoted string like "some {$foo} thing" failed https://github.com/smarty-php/smarty/issues/49

This commit is contained in:
Uwe Tews
2015-06-08 23:54:46 +02:00
parent d804454f21
commit f1e1f56ffe
6 changed files with 382 additions and 380 deletions

View File

@@ -1,4 +1,7 @@
 ===== 3.1.25-dev===== (xx.xx.2015)  ===== 3.1.25-dev===== (xx.xx.2015)
08.06.2015
- bugfix using {$foo} as array index like $bar.{$foo} or in double quoted string like "some {$foo} thing" failed https://github.com/smarty-php/smarty/issues/49
04.06.2015 04.06.2015
- bugfix possible error message on unset() while compiling {block} tags https://github.com/smarty-php/smarty/issues/46 - bugfix possible error message on unset() while compiling {block} tags https://github.com/smarty-php/smarty/issues/46

View File

@@ -397,9 +397,16 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
ldel dollar id nocacherdel { ldel dollar id nocacherdel {
if ($this->_yy_stack[count($this->_yy_stack)-1] == self::TEXT) {
$this->yypopstate(); $this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT; $this->token = Smarty_Internal_Templateparser::TP_SIMPLEOUTPUT;
$this->taglineno = $this->line; $this->taglineno = $this->line;
} else {
$this->value = $this->smarty->left_delimiter;
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
} }
ldel slash { ldel slash {
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;

View File

@@ -320,7 +320,7 @@ smartytag(res) ::= tag(t) RDEL. {
// //
// output tags start here // output tags start here
// //
smartytag(res) ::= SIMPELOUTPUT(i). { smartytag(res) ::= SIMPLEOUTPUT(i). {
$var = trim(substr(i, $this->lex->ldel_length, -$this->lex->rdel_length), ' $'); $var = trim(substr(i, $this->lex->ldel_length, -$this->lex->rdel_length), ' $');
if (preg_match('/^(.*)(\s+nocache)$/', $var, $match)) { if (preg_match('/^(.*)(\s+nocache)$/', $var, $match)) {
res = $this->compiler->compileTag('private_print_expression',array('nocache'),array('value'=>$this->compiler->compileVariable('\''.$match[1].'\''))); res = $this->compiler->compileTag('private_print_expression',array('nocache'),array('value'=>$this->compiler->compileVariable('\''.$match[1].'\'')));
@@ -948,7 +948,6 @@ indexdef(res) ::= DOT INTEGER(n). {
res = '['. n .']'; res = '['. n .']';
} }
indexdef(res) ::= DOT LDEL expr(e) RDEL. { indexdef(res) ::= DOT LDEL expr(e) RDEL. {
res = '['. e .']'; res = '['. e .']';
} }
@@ -1010,10 +1009,6 @@ varvar(res) ::= varvar(v1) varvarele(v2). {
varvarele(res) ::= ID(s). { varvarele(res) ::= ID(s). {
res = '\''.s.'\''; res = '\''.s.'\'';
} }
varvarele(res) ::= SIMPELOUTPUT(i). {
$var = trim(substr(i, $this->lex->ldel_length, -$this->lex->rdel_length), ' $');
res = $this->compiler->compileVariable('\''.$var.'\'');
}
// variable sections of element // variable sections of element
varvarele(res) ::= LDEL expr(e) RDEL. { varvarele(res) ::= LDEL expr(e) RDEL. {

View File

@@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.25-dev/3'; const SMARTY_VERSION = '3.1.25-dev/4';
/** /**
* define variable scopes * define variable scopes

View File

@@ -485,9 +485,16 @@ class Smarty_Internal_Templatelexer
function yy_r2_9() function yy_r2_9()
{ {
if ($this->_yy_stack[count($this->_yy_stack) - 1] == self::TEXT) {
$this->yypopstate(); $this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT; $this->token = Smarty_Internal_Templateparser::TP_SIMPLEOUTPUT;
$this->taglineno = $this->line; $this->taglineno = $this->line;
} else {
$this->value = $this->smarty->left_delimiter;
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
} }
function yy_r2_11() function yy_r2_11()

File diff suppressed because it is too large Load Diff