Skip to content

Commit

Permalink
Merge pull request civicrm#15 from kurund/smarty-upgrade
Browse files Browse the repository at this point in the history
CRM-12750 - upgrade smarty to 2.6.27
  • Loading branch information
totten committed Jun 3, 2013
2 parents cd02bee + 5c6ca1d commit 22ce79a
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 163 deletions.
2 changes: 1 addition & 1 deletion Smarty/Config_File.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* smarty-discussion-subscribe@googlegroups.com
*
* @link http://www.smarty.net/
* @version 2.6.26
* @version 2.6.25-dev
* @copyright Copyright: 2001-2005 New Digital Group, Inc.
* @author Andrei Zmievski <andrei@php.net>
* @access public
Expand Down
64 changes: 14 additions & 50 deletions Smarty/Smarty.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
*
* For questions, help, comments, discussion, etc., please join the
* Smarty mailing list. Send a blank e-mail to
* smarty-discussion-subscribe@googlegroups.com
* smarty-discussion-subscribe@googlegroups.com
*
* @link http://www.smarty.net/
* @copyright 2001-2005 New Digital Group, Inc.
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei@php.net>
* @package Smarty
* @version 2.6.26
* @version 2.6.27
*/

/* $Id: Smarty.class.php 3163 2009-06-17 14:39:24Z monte.ohrt $ */
/* $Id: Smarty.class.php 4660 2012-09-24 20:05:15Z uwe.tews@googlemail.com $ */

/**
* DIR_SEP isn't used anymore, but third party apps might
Expand Down Expand Up @@ -465,7 +465,7 @@ class Smarty
*
* @var string
*/
var $_version = '2.6.26';
var $_version = '2.6.27';

/**
* current template inclusion depth
Expand Down Expand Up @@ -1058,7 +1058,7 @@ function &get_template_vars($name=null)
} else {
// var non-existant, return valid reference
$_tmp = null;
return $_tmp;
return $_tmp;
}
}

Expand Down Expand Up @@ -1090,7 +1090,8 @@ function &get_config_vars($name=null)
*/
function trigger_error($error_msg, $error_type = E_USER_WARNING)
{
trigger_error("Smarty error: $error_msg", $error_type);
$msg = htmlentities($error_msg);
trigger_error("Smarty error: $msg", $error_type);
}


Expand All @@ -1117,7 +1118,7 @@ function display($resource_name, $cache_id = null, $compile_id = null)
function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false)
{
static $_cache_info = array();

$_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting)
? $this->error_reporting : error_reporting() & ~E_NOTICE);

Expand Down Expand Up @@ -1510,47 +1511,10 @@ function _compile_source($resource_name, &$source_content, &$compiled_content, $
*/
function _get_compile_path($resource_name)
{
$compilePath = $this->_get_auto_filename( $this->compile_dir,
$resource_name,
$this->_compile_id );
$compilePath .= '.php';

//for 'string:' resource smarty might going to fail to create
//compile file, so make sure we should have valid path, CRM-5890
$matches = array( );
if ( preg_match( '/^(\s+)?string:/', $resource_name, $matches ) ) {
if ( !$this->validateCompilePath( $compilePath ) ) {
$compilePath = $this->_get_auto_filename( $this->compile_dir,
time().rand(),
$this->_compile_id );
$compilePath .= '.php';
}
}

return $compilePath;
return $this->_get_auto_filename($this->compile_dir, $resource_name,
$this->_compile_id) . '.php';
}

/**
* do check can smarty create a file w/ given path.
*/
function validateCompilePath( $compilePath ) {
//first check for directory.
$dirname = dirname( $compilePath );
if ( !is_dir( $dirname ) ) {
require_once(SMARTY_CORE_DIR . 'core.create_dir_structure.php');
smarty_core_create_dir_structure( array('dir' => $dirname ), $this );
}

$isValid = false;
if ( $fd = @fopen( $compilePath, 'wb') ) {
$isValid = true;
@fclose( $fd );
@unlink($compilePath);
}

return $isValid;
}


/**
* fetch the template info. Gets timestamp, and source
* if get_source is true
Expand Down Expand Up @@ -1970,10 +1934,10 @@ function _eval($code, $params=null)
{
return eval($code);
}

/**
* Extracts the filter name from the given callback
*
*
* @param callback $function
* @return string
*/
Expand All @@ -1988,7 +1952,7 @@ function _get_filter_name($function)
return $function;
}
}

/**#@-*/

}
Expand Down
2 changes: 1 addition & 1 deletion Smarty/Smarty_Compiler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @link http://smarty.php.net/
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei@php.net>
* @version 2.6.26
* @version 2.6.25-dev
* @copyright 2001-2005 New Digital Group, Inc.
* @package Smarty
*/
Expand Down
6 changes: 5 additions & 1 deletion Smarty/plugins/function.cycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ function smarty_function_cycle($params, &$smarty)
$cycle_vars[$name]['values'] = $params['values'];
}

$cycle_vars[$name]['delimiter'] = (isset($params['delimiter'])) ? $params['delimiter'] : ',';
if (isset($params['delimiter'])) {
$cycle_vars[$name]['delimiter'] = $params['delimiter'];
} elseif (!isset($cycle_vars[$name]['delimiter'])) {
$cycle_vars[$name]['delimiter'] = ',';
}

if(is_array($cycle_vars[$name]['values'])) {
$cycle_array = $cycle_vars[$name]['values'];
Expand Down
9 changes: 1 addition & 8 deletions Smarty/plugins/function.eval.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/
function smarty_function_eval($params, &$smarty)
{
static $compiledCache = array( );

if (!isset($params['var'])) {
$smarty->trigger_error("eval: missing 'var' parameter");
Expand All @@ -31,13 +30,7 @@ function smarty_function_eval($params, &$smarty)
return;
}

$md5 = md5( $params['var'] );
if ( isset( $compiledCache[$md5] ) ) {
$_var_compiled = $compiledCache[$md5];
} else {
$smarty->_compile_source('evaluated template', $params['var'], $_var_compiled);
$compiledCache[$md5] = $_var_compiled;
}
$smarty->_compile_source('evaluated template', $params['var'], $_var_compiled);

ob_start();
$smarty->_eval('?>' . $_var_compiled);
Expand Down
4 changes: 2 additions & 2 deletions Smarty/plugins/function.fetch.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ function smarty_function_fetch($params, &$smarty)
$content .= fgets($fp,4096);
}
fclose($fp);
$csplit = split("\r\n\r\n",$content,2);
$csplit = preg_split("!\r\n\r\n!",$content,2);

$content = $csplit[1];

if(!empty($params['assign_headers'])) {
$smarty->assign($params['assign_headers'],split("\r\n",$csplit[0]));
$smarty->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0]));
}
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions Smarty/plugins/function.math.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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][a-zA-Z0-9_]+)!",$equation, $match);
preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!",$equation, $match);
$allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10',
'max','min','pi','pow','rand','round','sin','sqrt','srand','tan');

Expand Down Expand Up @@ -82,4 +82,4 @@ function smarty_function_math($params, &$smarty)

/* vim: set expandtab: */

?>
?>
98 changes: 0 additions & 98 deletions Smarty/plugins/modifier.print_array.php

This file was deleted.

0 comments on commit 22ce79a

Please sign in to comment.