change embedded variable logic to only recognize $foo and $foo[0][bar] syntax

This commit is contained in:
mohrt
2003-02-19 16:25:47 +00:00
parent d190c1c8fd
commit 2cd256d4fc
3 changed files with 6 additions and 4 deletions

2
NEWS
View File

@@ -1,3 +1,5 @@
- change embedded variable logic to only recognize $foo and
$foo[0][bar] syntax (Monte)
- allow null as function attribute value - allow null as function attribute value
(Andr<64> Rabold, Monte) (Andr<64> Rabold, Monte)
- support $foo->bar[index] syntax (Monte) - support $foo->bar[index] syntax (Monte)

View File

@@ -1446,7 +1446,7 @@ class Smarty_Compiler extends Smarty {
function _expand_quoted_text($var_expr) function _expand_quoted_text($var_expr)
{ {
// if contains unescaped $, expand it // if contains unescaped $, expand it
if(preg_match_all('|(?<!\\\\)\$' . $this->_dvar_guts_regexp . '|', $var_expr, $match)) { if(preg_match_all('|(?<!\\\\)\$\w+(?:' . $this->_var_bracket_regexp . ')*|', $var_expr, $match)) {
rsort($match[0]); rsort($match[0]);
reset($match[0]); reset($match[0]);
foreach($match[0] as $var) { foreach($match[0] as $var) {
@@ -1533,7 +1533,7 @@ class Smarty_Compiler extends Smarty {
} }
// look for variables imbedded in quoted strings, replace them // look for variables imbedded in quoted strings, replace them
if(preg_match('!' . $this->_qstr_regexp . '!', $output, $match)) { if(preg_match('|(?<!\\\\)\$|', $output, $match)) {
$output = str_replace($match[0], $this->_expand_quoted_text($match[0]), $output); $output = str_replace($match[0], $this->_expand_quoted_text($match[0]), $output);
} }

View File

@@ -1446,7 +1446,7 @@ class Smarty_Compiler extends Smarty {
function _expand_quoted_text($var_expr) function _expand_quoted_text($var_expr)
{ {
// if contains unescaped $, expand it // if contains unescaped $, expand it
if(preg_match_all('|(?<!\\\\)\$' . $this->_dvar_guts_regexp . '|', $var_expr, $match)) { if(preg_match_all('|(?<!\\\\)\$\w+(?:' . $this->_var_bracket_regexp . ')*|', $var_expr, $match)) {
rsort($match[0]); rsort($match[0]);
reset($match[0]); reset($match[0]);
foreach($match[0] as $var) { foreach($match[0] as $var) {
@@ -1533,7 +1533,7 @@ class Smarty_Compiler extends Smarty {
} }
// look for variables imbedded in quoted strings, replace them // look for variables imbedded in quoted strings, replace them
if(preg_match('!' . $this->_qstr_regexp . '!', $output, $match)) { if(preg_match('|(?<!\\\\)\$|', $output, $match)) {
$output = str_replace($match[0], $this->_expand_quoted_text($match[0]), $output); $output = str_replace($match[0], $this->_expand_quoted_text($match[0]), $output);
} }