mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 18:04:26 +02:00
cleaned up logic of if statement security
This commit is contained in:
@@ -485,15 +485,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
$is_arg_stack = array();
|
$is_arg_stack = array();
|
||||||
|
|
||||||
for ($i = 0; $i < count($tokens); $i++) {
|
for ($i = 0; $i < count($tokens); $i++) {
|
||||||
|
|
||||||
if($this->security
|
|
||||||
&& $tokens[$i+1] == '('
|
|
||||||
&& !preg_match("|[^a-zA-Z_-]+|",$tokens[$i])
|
|
||||||
&& !in_array($tokens[$i],array('eq','ne','neq','lt','le','lte','gt','ge','gte','and','or','not','mod','is'))
|
|
||||||
&& !in_array($tokens[$i],$this->security_settings["ALLOW_IF_FUNCS"])) {
|
|
||||||
$this->_syntax_error("(secure mode) '".$tokens[$i]."' not allowed in if statement");
|
|
||||||
}
|
|
||||||
|
|
||||||
$token = &$tokens[$i];
|
$token = &$tokens[$i];
|
||||||
switch ($token) {
|
switch ($token) {
|
||||||
case 'eq':
|
case 'eq':
|
||||||
@@ -569,6 +561,14 @@ class Smarty_Compiler extends Smarty {
|
|||||||
current position for the next iteration. */
|
current position for the next iteration. */
|
||||||
$i = $is_arg_start;
|
$i = $is_arg_start;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
if($this->security
|
||||||
|
&& $tokens[$i+1] == '('
|
||||||
|
&& !preg_match("|[^a-zA-Z_-]|",$tokens[$i])
|
||||||
|
&& !in_array($tokens[$i],$this->security_settings["ALLOW_IF_FUNCS"])) {
|
||||||
|
$this->_syntax_error("(secure mode) '".$tokens[$i]."' not allowed in if statement");
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -485,15 +485,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
$is_arg_stack = array();
|
$is_arg_stack = array();
|
||||||
|
|
||||||
for ($i = 0; $i < count($tokens); $i++) {
|
for ($i = 0; $i < count($tokens); $i++) {
|
||||||
|
|
||||||
if($this->security
|
|
||||||
&& $tokens[$i+1] == '('
|
|
||||||
&& !preg_match("|[^a-zA-Z_-]+|",$tokens[$i])
|
|
||||||
&& !in_array($tokens[$i],array('eq','ne','neq','lt','le','lte','gt','ge','gte','and','or','not','mod','is'))
|
|
||||||
&& !in_array($tokens[$i],$this->security_settings["ALLOW_IF_FUNCS"])) {
|
|
||||||
$this->_syntax_error("(secure mode) '".$tokens[$i]."' not allowed in if statement");
|
|
||||||
}
|
|
||||||
|
|
||||||
$token = &$tokens[$i];
|
$token = &$tokens[$i];
|
||||||
switch ($token) {
|
switch ($token) {
|
||||||
case 'eq':
|
case 'eq':
|
||||||
@@ -569,6 +561,14 @@ class Smarty_Compiler extends Smarty {
|
|||||||
current position for the next iteration. */
|
current position for the next iteration. */
|
||||||
$i = $is_arg_start;
|
$i = $is_arg_start;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
if($this->security
|
||||||
|
&& $tokens[$i+1] == '('
|
||||||
|
&& !preg_match("|[^a-zA-Z_-]|",$tokens[$i])
|
||||||
|
&& !in_array($tokens[$i],$this->security_settings["ALLOW_IF_FUNCS"])) {
|
||||||
|
$this->_syntax_error("(secure mode) '".$tokens[$i]."' not allowed in if statement");
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user