summaryrefslogtreecommitdiff
path: root/lexer
diff options
context:
space:
mode:
authorUwe Tews <uwe.tews@googlemail.com>2015-06-08 23:54:46 +0200
committerUwe Tews <uwe.tews@googlemail.com>2015-06-08 23:54:46 +0200
commitf1e1f56ffe85b4a8f7f238bd33024ff1e14905d7 (patch)
tree22e981658eee6e298e2884f62e885853963f047f /lexer
parentd804454f21015df3c980db3962008b28147ed289 (diff)
downloadsmarty-f1e1f56ffe85b4a8f7f238bd33024ff1e14905d7.tar.gz
smarty-f1e1f56ffe85b4a8f7f238bd33024ff1e14905d7.tar.bz2
smarty-f1e1f56ffe85b4a8f7f238bd33024ff1e14905d7.zip
- 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
Diffstat (limited to 'lexer')
-rw-r--r--lexer/smarty_internal_templatelexer.plex13
-rw-r--r--lexer/smarty_internal_templateparser.y7
2 files changed, 11 insertions, 9 deletions
diff --git a/lexer/smarty_internal_templatelexer.plex b/lexer/smarty_internal_templatelexer.plex
index c6164813..e36df597 100644
--- a/lexer/smarty_internal_templatelexer.plex
+++ b/lexer/smarty_internal_templatelexer.plex
@@ -397,9 +397,16 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line;
}
ldel dollar id nocacherdel {
- $this->yypopstate();
- $this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT;
- $this->taglineno = $this->line;
+ if ($this->_yy_stack[count($this->_yy_stack)-1] == self::TEXT) {
+ $this->yypopstate();
+ $this->token = Smarty_Internal_Templateparser::TP_SIMPLEOUTPUT;
+ $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 {
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
diff --git a/lexer/smarty_internal_templateparser.y b/lexer/smarty_internal_templateparser.y
index c41dfc4e..341c99f8 100644
--- a/lexer/smarty_internal_templateparser.y
+++ b/lexer/smarty_internal_templateparser.y
@@ -320,7 +320,7 @@ smartytag(res) ::= tag(t) RDEL. {
//
// output tags start here
//
-smartytag(res) ::= SIMPELOUTPUT(i). {
+smartytag(res) ::= SIMPLEOUTPUT(i). {
$var = trim(substr(i, $this->lex->ldel_length, -$this->lex->rdel_length), ' $');
if (preg_match('/^(.*)(\s+nocache)$/', $var, $match)) {
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 .']';
}
-
indexdef(res) ::= DOT LDEL expr(e) RDEL. {
res = '['. e .']';
}
@@ -1010,10 +1009,6 @@ varvar(res) ::= varvar(v1) varvarele(v2). {
varvarele(res) ::= ID(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
varvarele(res) ::= LDEL expr(e) RDEL. {