Skip to content

Commit

Permalink
Merge pull request #208 from seamuslee001/smarty_2_6_31
Browse files Browse the repository at this point in the history
Upgrade Smarty to 2.6.31 to solve issues on PHP7.2
  • Loading branch information
totten authored May 15, 2018
2 parents 4794c1c + 9cc7df8 commit 93f590c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Smarty/Smarty.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <[email protected]>
* @package Smarty
* @version 2.6.30
* @version 2.6.31-dev
*/

/* $Id$ */
Expand Down Expand Up @@ -465,7 +465,7 @@ class Smarty
*
* @var string
*/
var $_version = '2.6.30';
var $_version = '2.6.31';

/**
* current template inclusion depth
Expand Down
16 changes: 8 additions & 8 deletions Smarty/Smarty_Compiler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,9 @@ function _compile_file($resource_name, $source_content, &$compiled_content)

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

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

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

case '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");
/* the number of matched elements in the regexp in _compile_file()
determins the type of folded tag that was found */
Expand Down Expand Up @@ -754,7 +749,12 @@ function _compile_block_tag($tag_command, $tag_args, $tag_modifier, &$output)
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
*
Expand Down
7 changes: 4 additions & 3 deletions Smarty/plugins/function.math.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
*/
function smarty_function_math($params, &$smarty)
{
static $_allowed_funcs = array('int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true,
'log' => true, 'log10' => true, 'max' => true, 'min' => true, 'pi' => true, 'pow' => true, 'rand' => true,
'round' => true, 'sin' => true, 'sqrt' => true, 'srand' => true, 'tan' => true);
static $_allowed_funcs = array('int' => TRUE, 'abs' => TRUE, 'ceil' => TRUE, 'cos' => TRUE, 'exp' => TRUE, 'floor' => TRUE,
'log' => TRUE, 'log10' => TRUE, 'max' => TRUE, 'min' => TRUE, 'pi' => TRUE, 'pow' => TRUE, 'rand' => TRUE,
'round' => TRUE, 'sin' => TRUE, 'sqrt' => TRUE, 'srand' => TRUE, 'tan' => TRUE);
// be sure equation parameter is present
if (empty($params['equation'])) {
trigger_error("math: missing equation parameter", E_USER_WARNING);
Expand Down Expand Up @@ -72,6 +72,7 @@ function smarty_function_math($params, &$smarty)
}
}
}

// 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);

Expand Down

0 comments on commit 93f590c

Please sign in to comment.