mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
few more fixes, spaces around function parameters
This commit is contained in:
@@ -153,7 +153,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
// "text"
|
// "text"
|
||||||
// "text"|bar
|
// "text"|bar
|
||||||
// $foo->bar()
|
// $foo->bar()
|
||||||
$this->_param_regexp = '(?:(?:' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '|\w+)' . $this->_mod_regexp . ')';
|
$this->_param_regexp = '(?:\s*(?:' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '|\w+)' . $this->_mod_regexp . '\s*)';
|
||||||
|
|
||||||
// matches valid parenthesised function parameters:
|
// matches valid parenthesised function parameters:
|
||||||
//
|
//
|
||||||
@@ -161,14 +161,14 @@ class Smarty_Compiler extends Smarty {
|
|||||||
// $foo, $bar, "text"
|
// $foo, $bar, "text"
|
||||||
// $foo|bar, "foo"|bar, $foo->bar($foo)|bar
|
// $foo|bar, "foo"|bar, $foo->bar($foo)|bar
|
||||||
$this->_parenth_param_regexp = '(?:\((?:' . $this->_param_regexp
|
$this->_parenth_param_regexp = '(?:\((?:' . $this->_param_regexp
|
||||||
. '(?:\s*,\s*(?:' . $this->_param_regexp . '))*)?\))';
|
. '(?:,(?:' . $this->_param_regexp . '))*)?\))';
|
||||||
|
|
||||||
// matches valid function call:
|
// matches valid function call:
|
||||||
// foo()
|
// foo()
|
||||||
// foo_bar($foo)
|
// foo_bar($foo)
|
||||||
// _foo_bar($foo,"bar")
|
// _foo_bar($foo,"bar")
|
||||||
// foo123($foo,$foo->bar(),"foo")
|
// foo123($foo,$foo->bar(),"foo")
|
||||||
$this->_func_call_regexp = '(?:' . $this->_func_regexp . '(?:' . $this->_parenth_param_regexp . '))';
|
$this->_func_call_regexp = '(?:' . $this->_func_regexp . '\s*(?:' . $this->_parenth_param_regexp . '))';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -947,7 +947,6 @@ class Smarty_Compiler extends Smarty {
|
|||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _compile_if_tag
|
Function: _compile_if_tag
|
||||||
Purpose: Compile {if ...} tag
|
Purpose: Compile {if ...} tag
|
||||||
@@ -961,7 +960,8 @@ class Smarty_Compiler extends Smarty {
|
|||||||
' . $this->_obj_call_regexp . $this->_mod_regexp . ' | # valid object call
|
' . $this->_obj_call_regexp . $this->_mod_regexp . ' | # valid object call
|
||||||
' . $this->_var_regexp . $this->_mod_regexp . ' | # var or quoted string
|
' . $this->_var_regexp . $this->_mod_regexp . ' | # var or quoted string
|
||||||
\d+|!==|<=>|==|!=|<=|=>|\&\&|\|\||\(|\)|,|\!|\^|=|<|>|\||\% | # valid non-word token
|
\d+|!==|<=>|==|!=|<=|=>|\&\&|\|\||\(|\)|,|\!|\^|=|<|>|\||\% | # valid non-word token
|
||||||
even|odd|neq|lte|gte|and|not|mod|eq|ne|lt|le|gt|ge|or|is|div|by|is # valid word token
|
\b(even|odd|neq|lte|gte|and|not|mod|div|eq|ne|lt|le|gt|ge|or|is|by)\b | # valid word token
|
||||||
|
\S+ # anything else
|
||||||
)/x', $tag_args, $match);
|
)/x', $tag_args, $match);
|
||||||
|
|
||||||
$tokens = $match[0];
|
$tokens = $match[0];
|
||||||
@@ -1063,6 +1063,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
if(preg_match('!^(' . $this->_func_regexp . ')(' . $this->_parenth_param_regexp . ')$!', $token, $match)) {
|
if(preg_match('!^(' . $this->_func_regexp . ')(' . $this->_parenth_param_regexp . ')$!', $token, $match)) {
|
||||||
|
// function call
|
||||||
if($this->security &&
|
if($this->security &&
|
||||||
$i+1 < count($tokens) &&
|
$i+1 < count($tokens) &&
|
||||||
$tokens[$i+1] == '(' &&
|
$tokens[$i+1] == '(' &&
|
||||||
@@ -1232,6 +1233,9 @@ class Smarty_Compiler extends Smarty {
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _parse_var_props($val)
|
function _parse_var_props($val)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$val = trim($val);
|
||||||
|
|
||||||
if(preg_match('!^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')' . $this->_mod_regexp . '$!', $val)) {
|
if(preg_match('!^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')' . $this->_mod_regexp . '$!', $val)) {
|
||||||
// $ variable or object
|
// $ variable or object
|
||||||
return $this->_parse_var($val);
|
return $this->_parse_var($val);
|
||||||
@@ -1263,7 +1267,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
}
|
}
|
||||||
elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) {
|
elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) {
|
||||||
// literal string
|
// literal string
|
||||||
return '"' . $val .'"';
|
return $this->_expand_quoted_text('"' . $val .'"');
|
||||||
}
|
}
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
@@ -153,7 +153,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
// "text"
|
// "text"
|
||||||
// "text"|bar
|
// "text"|bar
|
||||||
// $foo->bar()
|
// $foo->bar()
|
||||||
$this->_param_regexp = '(?:(?:' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '|\w+)' . $this->_mod_regexp . ')';
|
$this->_param_regexp = '(?:\s*(?:' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '|\w+)' . $this->_mod_regexp . '\s*)';
|
||||||
|
|
||||||
// matches valid parenthesised function parameters:
|
// matches valid parenthesised function parameters:
|
||||||
//
|
//
|
||||||
@@ -161,14 +161,14 @@ class Smarty_Compiler extends Smarty {
|
|||||||
// $foo, $bar, "text"
|
// $foo, $bar, "text"
|
||||||
// $foo|bar, "foo"|bar, $foo->bar($foo)|bar
|
// $foo|bar, "foo"|bar, $foo->bar($foo)|bar
|
||||||
$this->_parenth_param_regexp = '(?:\((?:' . $this->_param_regexp
|
$this->_parenth_param_regexp = '(?:\((?:' . $this->_param_regexp
|
||||||
. '(?:\s*,\s*(?:' . $this->_param_regexp . '))*)?\))';
|
. '(?:,(?:' . $this->_param_regexp . '))*)?\))';
|
||||||
|
|
||||||
// matches valid function call:
|
// matches valid function call:
|
||||||
// foo()
|
// foo()
|
||||||
// foo_bar($foo)
|
// foo_bar($foo)
|
||||||
// _foo_bar($foo,"bar")
|
// _foo_bar($foo,"bar")
|
||||||
// foo123($foo,$foo->bar(),"foo")
|
// foo123($foo,$foo->bar(),"foo")
|
||||||
$this->_func_call_regexp = '(?:' . $this->_func_regexp . '(?:' . $this->_parenth_param_regexp . '))';
|
$this->_func_call_regexp = '(?:' . $this->_func_regexp . '\s*(?:' . $this->_parenth_param_regexp . '))';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -947,7 +947,6 @@ class Smarty_Compiler extends Smarty {
|
|||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _compile_if_tag
|
Function: _compile_if_tag
|
||||||
Purpose: Compile {if ...} tag
|
Purpose: Compile {if ...} tag
|
||||||
@@ -961,7 +960,8 @@ class Smarty_Compiler extends Smarty {
|
|||||||
' . $this->_obj_call_regexp . $this->_mod_regexp . ' | # valid object call
|
' . $this->_obj_call_regexp . $this->_mod_regexp . ' | # valid object call
|
||||||
' . $this->_var_regexp . $this->_mod_regexp . ' | # var or quoted string
|
' . $this->_var_regexp . $this->_mod_regexp . ' | # var or quoted string
|
||||||
\d+|!==|<=>|==|!=|<=|=>|\&\&|\|\||\(|\)|,|\!|\^|=|<|>|\||\% | # valid non-word token
|
\d+|!==|<=>|==|!=|<=|=>|\&\&|\|\||\(|\)|,|\!|\^|=|<|>|\||\% | # valid non-word token
|
||||||
even|odd|neq|lte|gte|and|not|mod|eq|ne|lt|le|gt|ge|or|is|div|by|is # valid word token
|
\b(even|odd|neq|lte|gte|and|not|mod|div|eq|ne|lt|le|gt|ge|or|is|by)\b | # valid word token
|
||||||
|
\S+ # anything else
|
||||||
)/x', $tag_args, $match);
|
)/x', $tag_args, $match);
|
||||||
|
|
||||||
$tokens = $match[0];
|
$tokens = $match[0];
|
||||||
@@ -1063,6 +1063,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
if(preg_match('!^(' . $this->_func_regexp . ')(' . $this->_parenth_param_regexp . ')$!', $token, $match)) {
|
if(preg_match('!^(' . $this->_func_regexp . ')(' . $this->_parenth_param_regexp . ')$!', $token, $match)) {
|
||||||
|
// function call
|
||||||
if($this->security &&
|
if($this->security &&
|
||||||
$i+1 < count($tokens) &&
|
$i+1 < count($tokens) &&
|
||||||
$tokens[$i+1] == '(' &&
|
$tokens[$i+1] == '(' &&
|
||||||
@@ -1232,6 +1233,9 @@ class Smarty_Compiler extends Smarty {
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _parse_var_props($val)
|
function _parse_var_props($val)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$val = trim($val);
|
||||||
|
|
||||||
if(preg_match('!^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')' . $this->_mod_regexp . '$!', $val)) {
|
if(preg_match('!^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')' . $this->_mod_regexp . '$!', $val)) {
|
||||||
// $ variable or object
|
// $ variable or object
|
||||||
return $this->_parse_var($val);
|
return $this->_parse_var($val);
|
||||||
@@ -1263,7 +1267,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
}
|
}
|
||||||
elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) {
|
elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) {
|
||||||
// literal string
|
// literal string
|
||||||
return '"' . $val .'"';
|
return $this->_expand_quoted_text('"' . $val .'"');
|
||||||
}
|
}
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user