Skip to content

Commit

Permalink
[libs:smarty] update to Smarty 2.6.31
Browse files Browse the repository at this point in the history
  • Loading branch information
nao-pon committed Nov 3, 2017
1 parent 1929793 commit 7556e90
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
12 changes: 6 additions & 6 deletions xoops_trust_path/libs/smarty/Smarty.class.php
Expand Up @@ -27,7 +27,7 @@
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei@php.net> * @author Andrei Zmievski <andrei@php.net>
* @package Smarty * @package Smarty
* @version 2.6.30 * @version 2.6.31-dev
*/ */


/* $Id$ */ /* $Id$ */
Expand Down Expand Up @@ -63,10 +63,6 @@
*/ */
class Smarty class Smarty
{ {
/**#@+
* Smarty Configuration Section
*/

/** /**
* For backward compatibility of XOOPS Cube * For backward compatibility of XOOPS Cube
*/ */
Expand All @@ -75,6 +71,10 @@ public function Smarty()
self::__construct(); self::__construct();
} }


/**#@+
* Smarty Configuration Section
*/

/** /**
* The name of the directory where templates are located. * The name of the directory where templates are located.
* *
Expand Down Expand Up @@ -473,7 +473,7 @@ public function Smarty()
* *
* @var string * @var string
*/ */
var $_version = '2.6.30'; var $_version = '2.6.31';


/** /**
* current template inclusion depth * current template inclusion depth
Expand Down
17 changes: 8 additions & 9 deletions xoops_trust_path/libs/smarty/Smarty_Compiler.class.php
Expand Up @@ -33,7 +33,6 @@
* @package Smarty * @package Smarty
*/ */
class Smarty_Compiler extends Smarty { class Smarty_Compiler extends Smarty {

/** /**
* For backward compatibility of XOOPS Cube * For backward compatibility of XOOPS Cube
*/ */
Expand Down Expand Up @@ -267,14 +266,9 @@ function _compile_file($resource_name, $source_content, &$compiled_content)


preg_match_all($search, $source_content, $match, PREG_SET_ORDER); preg_match_all($search, $source_content, $match, PREG_SET_ORDER);
$this->_folded_blocks = $match; $this->_folded_blocks = $match;
reset($this->_folded_blocks);


/* replace special blocks by "{php}" */ /* replace special blocks by "{php}" */
$source_content = preg_replace_callback($search, create_function ('$matches', "return '" $source_content = preg_replace_callback($search, array($this,'_preg_callback')
. $this->_quote_replace($this->left_delimiter) . 'php'
. "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
. $this->_quote_replace($this->right_delimiter)
. "';")
, $source_content); , $source_content);


/* Gather all template tags. */ /* Gather all template tags. */
Expand Down Expand Up @@ -564,7 +558,7 @@ function _compile_tag($template_tag)


case 'php': case 'php':
/* handle folded tags replaced by {php} */ /* handle folded tags replaced by {php} */
list(, $block) = each($this->_folded_blocks); $block = array_shift($this->_folded_blocks);
$this->_current_line_no += substr_count($block[0], "\n"); $this->_current_line_no += substr_count($block[0], "\n");
/* the number of matched elements in the regexp in _compile_file() /* the number of matched elements in the regexp in _compile_file()
determins the type of folded tag that was found */ determins the type of folded tag that was found */
Expand Down Expand Up @@ -762,7 +756,12 @@ function _compile_block_tag($tag_command, $tag_args, $tag_modifier, &$output)
return true; return true;
} }



function _preg_callback ($matches) {
return $this->_quote_replace($this->left_delimiter)
. 'php'
. str_repeat("\n", substr_count($matches[1], "\n"))
. $this->_quote_replace($this->right_delimiter);
}
/** /**
* compile custom function tag * compile custom function tag
* *
Expand Down
37 changes: 21 additions & 16 deletions xoops_trust_path/libs/smarty/plugins/function.math.php
Expand Up @@ -18,11 +18,11 @@
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* *
* @param array $params parameters * @param array $params parameters
* @param Smarty_Internal_Template $template template object * @param Smarty
* *
* @return string|null * @return string|null
*/ */
function smarty_function_math($params, $template) function smarty_function_math($params, &$smarty)
{ {
static $_allowed_funcs = static $_allowed_funcs =
array('int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true, array('int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true,
Expand Down Expand Up @@ -58,30 +58,35 @@ function smarty_function_math($params, $template)
return; return;
} }


foreach ($params as $key => $val) {
if ($key != "equation" && $key != "format" && $key != "assign") {
// make sure value is not empty
if (strlen($val) == 0) {
trigger_error("math: parameter '{$key}' is empty", E_USER_WARNING);

return;
}
if (!is_numeric($val)) {
trigger_error("math: parameter '{$key}' is not numeric", E_USER_WARNING);

return;
}
}
}

// match all vars in equation, make sure all are passed // match all vars in equation, make sure all are passed
preg_match_all('!(?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)!', $equation, $match); preg_match_all('!(?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)!', $equation, $match);


foreach ($match[ 1 ] as $curr_var) { foreach ($match[ 1 ] as $curr_var) {
if ($curr_var && !isset($params[ $curr_var ]) && !isset($_allowed_funcs[ $curr_var ])) { if ($curr_var && !isset($params[ $curr_var ]) && !isset($_allowed_funcs[ $curr_var ])) {
trigger_error("math: function call $curr_var not allowed", E_USER_WARNING); trigger_error("math: function call '{$curr_var}' not allowed, or missing parameter '{$curr_var}'", E_USER_WARNING);


return; return;
} }
} }


foreach ($params as $key => $val) { foreach ($params as $key => $val) {
if ($key != "equation" && $key != "format" && $key != "assign") { if ($key != "equation" && $key != "format" && $key != "assign") {
// make sure value is not empty
if (strlen($val) == 0) {
trigger_error("math: parameter $key is empty", E_USER_WARNING);

return;
}
if (!is_numeric($val)) {
trigger_error("math: parameter $key: is not numeric", E_USER_WARNING);

return;
}
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation); $equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
} }
} }
Expand All @@ -92,13 +97,13 @@ function smarty_function_math($params, $template)
if (empty($params[ 'assign' ])) { if (empty($params[ 'assign' ])) {
return $smarty_math_result; return $smarty_math_result;
} else { } else {
$template->assign($params[ 'assign' ], $smarty_math_result); $smarty->assign($params[ 'assign' ], $smarty_math_result);
} }
} else { } else {
if (empty($params[ 'assign' ])) { if (empty($params[ 'assign' ])) {
printf($params[ 'format' ], $smarty_math_result); printf($params[ 'format' ], $smarty_math_result);
} else { } else {
$template->assign($params[ 'assign' ], sprintf($params[ 'format' ], $smarty_math_result)); $smarty->assign($params[ 'assign' ], sprintf($params[ 'format' ], $smarty_math_result));
} }
} }
} }

0 comments on commit 7556e90

Please sign in to comment.