mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
fix more object calling syntax issues
This commit is contained in:
@@ -159,7 +159,7 @@ class Smarty_Compiler extends Smarty {
|
||||
$this->_obj_params_regexp = '\((?:' . $this->_obj_single_param_regexp
|
||||
. '(?:\s*,\s*' . $this->_obj_single_param_regexp . ')*)?\)';
|
||||
$this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:' . $this->_obj_ext_regexp . ')+)';
|
||||
$this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . ')?)';
|
||||
$this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . ')?(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?)';
|
||||
|
||||
// matches valid modifier syntax:
|
||||
// |foo
|
||||
@@ -1667,15 +1667,12 @@ class Smarty_Compiler extends Smarty {
|
||||
function _parse_var($var_expr)
|
||||
{
|
||||
$_has_math = false;
|
||||
|
||||
if(!preg_match('~^' . $this->_obj_call_regexp . '$~', $var_expr)) {
|
||||
// not an object call, see if there is math to parse
|
||||
$_math_vars = preg_split('~('.$this->_dvar_math_regexp.'|'.$this->_qstr_regexp.')~', $var_expr, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
|
||||
if(count($_math_vars) > 1) {
|
||||
$_first_var = '';
|
||||
$_complete_var = '';
|
||||
$_output = '';
|
||||
$_first_var = "";
|
||||
$_complete_var = "";
|
||||
$_output = "";
|
||||
// simple check if there is any math, to stop recursion (due to modifiers with "xx % yy" as parameter)
|
||||
foreach($_math_vars as $_k => $_math_var) {
|
||||
$_math_var = $_math_vars[$_k];
|
||||
@@ -1694,7 +1691,7 @@ class Smarty_Compiler extends Smarty {
|
||||
if(empty($_first_var))
|
||||
$_first_var = $_complete_var;
|
||||
|
||||
$_complete_var = '';
|
||||
$_complete_var = "";
|
||||
} else {
|
||||
$_complete_var .= $_math_var;
|
||||
}
|
||||
@@ -1708,7 +1705,6 @@ class Smarty_Compiler extends Smarty {
|
||||
$var_expr = $_complete_var;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// prevent cutting of first digit in the number (we _definitly_ got a number if the first char is a digit)
|
||||
if(is_numeric($var_expr{0}))
|
||||
@@ -1717,10 +1713,11 @@ class Smarty_Compiler extends Smarty {
|
||||
$_var_ref = substr($var_expr, 1);
|
||||
|
||||
if(!$_has_math) {
|
||||
// get [foo] and .foo and ->foo and (...) pieces
|
||||
preg_match_all('~(?:^\w+)|' . $this->_obj_params_regexp . '|(?:' . $this->_var_bracket_regexp . ')|->\$?\w+|\.\$?\w+|\S+~', $_var_ref, $_match);
|
||||
|
||||
$_indexes = $_match[0];
|
||||
// get [foo] and .foo and ->foo and (...) pieces
|
||||
preg_match_all('~(?:^\w+)|' . $this->_obj_params_regexp . '|(?:' . $this->_var_bracket_regexp . ')|->\$?\w+|\.\$?\w+|\S+~', $_var_ref, $match);
|
||||
|
||||
$_indexes = $match[0];
|
||||
$_var_name = array_shift($_indexes);
|
||||
|
||||
/* Handle $smarty.* variable references as a special case. */
|
||||
|
Reference in New Issue
Block a user