Compare commits

...

16 Commits

Author SHA1 Message Date
Simon Wisselink 2f3595a1ab Merge branch 'release/2.6.32' into support/2.6 2021-10-22 16:42:38 +02:00
Simon Wisselink ee586702aa version bump 2021-10-22 16:42:36 +02:00
Simon Wisselink 22329d9d30 removed debug code 2021-10-22 16:42:17 +02:00
Simon Wisselink e361b0329b removed dangling version nrs, added release-script, updated changelog as far as it goes 2021-10-22 16:40:38 +02:00
Max Hayman bace28e2eb switch from @count() to empty(). Empty checks if the value is set where as count doesn't and causes errors. Similar to 305bf858c1 (#681) 2021-10-22 15:38:44 +02:00
mohrt 478f8a29b4 Merge pull request #544 from carpii/Smarty2
allow StdClass to be cast to array when compiling foreach, to prevent invalid count warning in PHP 7.2+
2020-01-13 18:47:40 -06:00
carpii f8717a6cf7 allow StdClass to be cast to array when compiling foreach, to prevent invalid count warning in PHP 7.2+ 2019-06-14 20:44:58 +07:00
uwetews 957f9ce43a Merge pull request #382 from cweiske/patch-1
Fix headlines in markdown text
2018-03-17 07:43:49 +01:00
Uwe Tews 4ab9757b49 replace functions deprecated in PHP 7.2 2017-11-03 07:39:13 +01:00
Uwe Tews 23d29f2ea3 Update ignored files 2017-11-03 07:31:18 +01:00
Christian Weiske 88cc17fe8e Fix headlines in markdown text 2017-08-11 20:53:18 +02:00
uwetews 5fb8387027 * {math} fix parameter checking order to avoid misleading message
* {math} replace wrong versiom https://github.com/smarty-php/smarty/issues/265
2016-09-11 00:51:19 +02:00
uwetews c5c9d6514c {math} shell injection vulnerability patch provided by Tim Weber 2016-07-19 20:31:12 +02:00
uwetews 4cb07a89e2 * fixed plugin filepath cache must not be static, because of possible problem
when using multiple Smarty instances with diffrent plugins_dir settings
         https://github.com/smarty-php/smarty/issues/146
2015-12-30 17:07:54 +01:00
Uwe Tews 47fa66cdcf Release 2.6.29 2015-06-21 15:10:14 +02:00
Uwe Tews e97b7d136c * PHP7 raises E_DEPRECATED use __construct for compatibility 2015-06-21 15:00:26 +02:00
13 changed files with 178 additions and 125 deletions
+11 -7
View File
@@ -1,7 +1,11 @@
* text=auto !eol
docs/chm/make_chm_spc.gif -text
docs/fop/thryb.ttf -text
docs/fop/thrybi.ttf -text
docs/fop/thryi.ttf -text
docs/fop/thryn.ttf -text
misc/smarty_icon.gif -text
# Auto detect text files and perform LF normalization
* text=auto
# exclude from git export
/travis.ini export-ignore
/myconfig.ini export-ignore
/.travis.yml export-ignore
/.gitignore export-ignore
/.gitattributes export-ignore
/lexer/ export-ignore
/utilities/ export-ignore
+10 -19
View File
@@ -1,19 +1,10 @@
docs/*.cache
docs/*.fot
docs/Makefile
docs/chm/*.chm
docs/chm/*.hh?
docs/chm/fancy
docs/config.*
docs/configure
docs/diff
docs/dsssl/html-common.dsl
docs/entities/file-entities.ent
docs/entities/version.ent
docs/html
docs/manual.pdf
docs/manual.xml
docs/phpweb
docs/revcheck.html
docs/scripts/file-entities.php
/templates_c
.idea/
# Smarty
lexer/*.php
lexer/*.php.bak
lexer/*.out
utilies/*.php
/composer.lock
/vendor
/tests
+35 -14
View File
@@ -1,21 +1,42 @@
2013-09-30
=== Unreleased ===
* Fixed old vulnerability bug https://bugs.gentoo.org/show_bug.cgi?id=356615
=== 2.6.32 - 2021-10-22 ===
2013-07-16 Uwe Tews
=== 2.6.31 - 2017-11-03 ===
- replace functions deprecated in PHP 7.2
- {math} fix parameter checking order to avoid misleading message
- {math} replace wrong versiom
* Fixed made Smarty_Compiler.class.php compatible with PHP 5.5
=== 2.6.30 - 2016-07-19 ===
- {math} shell injection vulnerability patch provided by Tim Weber
- fixed plugin filepath cache must not be static, because of possible problem
when using multiple Smarty instances with diffrent plugins_dir settings
https://github.com/smarty-php/smarty/issues/146
=== 2.6.29 - 2015-06-21 ===
- PHP7 raises E_DEPRECATED use __construct for compatibility
=== 2.6.28 - 2013-09-30 ===
- Fixed old vulnerability bug https://bugs.gentoo.org/show_bug.cgi?id=356615
- Fixed made Smarty_Compiler.class.php compatible with PHP 5.5
=== 2.6.27 - 2012-09-24===
- Fixed escape Smarty error messages to avoid possible script execution
- Fixed security hole in {math} plugin
=== 2.6.26 - 2014-10-31 ===
- revert super global access changes, and instead rely on
- USE_SUPER_GLOBALS for security
=== 2.6.25 - 2009-05-19 ===
- fix E_NOTICE when sessions are disabled (mohrt)
=== 2.6.24 - 2009-05-16 ===
- fix problem introduced with super global changes (mohrt)
2012-09-24 Uwe Tews
=== Older versions ===
* Fixed escape Smarty error messages to avoid possible script execution
2010-04-17 Uwe Tews
* Fixed security hole in {math} plugin
2007-09-27 TAKAGI Masahiro <matakagi@gmail.com>
* docs/ja/designers/language-custom-functions/language-function-html-checkboxes.xml:
@@ -770,7 +791,7 @@
docs/fr/programmers/plugins/plugins-inserts.xml:
sync with EN
2006-10-14 Fernando Correa da Conceição <fernando_conceicao@yahoo.com.br>
2006-10-14 Fernando Correa da Conceio <fernando_conceicao@yahoo.com.br>
* docs/pt_BR/programmers/api-variables/variable-error-reporting.xml:
New Translation
@@ -4311,7 +4332,7 @@
fixed bug in _run_mod_handler
* libs/Smarty_Compiler.class.php:
fixed bug with autoload-handling of modifiers. thanks ándre.
fixed bug with autoload-handling of modifiers. thanks ndre.
2003-08-05 Messju Mohr <messju@lammfellpuschen.de>
+2 -2
View File
@@ -10,9 +10,9 @@ Copy the Smarty library files to your system. In our example, we place them in
/usr/local/lib/php/Smarty/
$> cd YOUR_DOWNLOAD_DIRECTORY
$> gtar -ztvf Smarty-2.6.7.tar.gz
$> gtar -ztvf Smarty-2.x.y.tar.gz
$> mkdir /usr/local/lib/php/Smarty
$> cp -r Smarty-2.6.7/libs/* /usr/local/lib/php/Smarty
$> cp -r Smarty-2.x.y/libs/* /usr/local/lib/php/Smarty
You should now have the following file structure:
-2
View File
@@ -3,8 +3,6 @@ NAME:
Smarty - the PHP compiling template engine
VERSION: 2.6.18
AUTHORS:
Monte Ohrt <monte at ohrt dot com>
+3 -9
View File
@@ -1,10 +1,10 @@
#Smarty 2 template engine
##Distribution repository
# Smarty 2 template engine
## Distribution repository
Starting with Smarty 2.6.23 Composer has been configured to load the packages from github.
**NOTE: Because of this change you must clear your local composer cache with the "composer clearcache" command**
To get the latest stable version use
To get the latest v2.6 release use
"require": {
"smarty/smarty": "~2.6"
@@ -12,12 +12,6 @@ To get the latest stable version use
in your composer.json file.
To get the trunk version use
"require": {
"smarty/smarty": "~2.6@dev"
}
The "smarty/smarty" package will start at libs/.... subfolder.
-6
View File
@@ -30,10 +30,4 @@
"libs/Config_File.class.php"
]
},
"extra": {
"branch-alias": {
"dev-master": "2.6.x-dev"
}
}
}
+1 -2
View File
@@ -22,7 +22,6 @@
* smarty-discussion-subscribe@googlegroups.com
*
* @link http://www.smarty.net/
* @version 2.6.25-dev
* @copyright Copyright: 2001-2005 New Digital Group, Inc.
* @author Andrei Zmievski <andrei@php.net>
* @access public
@@ -73,7 +72,7 @@ class Config_File {
*
* @param string $config_path (optional) path to the config files
*/
function Config_File($config_path = NULL)
public function __construct($config_path = NULL)
{
if (isset($config_path))
$this->set_path($config_path);
+9 -4
View File
@@ -27,7 +27,6 @@
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei@php.net>
* @package Smarty
* @version 2.6.25-dev
*/
/* $Id$ */
@@ -465,7 +464,7 @@ class Smarty
*
* @var string
*/
var $_version = '2.6.25-dev';
var $_version = '2.6.32';
/**
* current template inclusion depth
@@ -562,11 +561,17 @@ class Smarty
*/
var $_cache_including = false;
/**
* plugin filepath cache
*
* @var array
*/
var $_filepaths_cache = array();
/**#@-*/
/**
* The class constructor.
*/
function Smarty()
public function __construct()
{
$this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME']
: @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
@@ -1202,7 +1207,7 @@ class Smarty
$_server_vars = ($this->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
$_last_modified_date = @substr($_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_server_vars['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
$_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT';
if (@count($this->_cache_info['insert_tags']) == 0
if (empty($this->_cache_info['insert_tags'])
&& !$this->_cache_serials
&& $_gmt_mtime == $_last_modified_date) {
if (php_sapi_name()=='cgi')
+10 -11
View File
@@ -21,7 +21,6 @@
* @link http://smarty.php.net/
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei@php.net>
* @version 2.6.25-dev
* @copyright 2001-2005 New Digital Group, Inc.
* @package Smarty
*/
@@ -78,7 +77,7 @@ class Smarty_Compiler extends Smarty {
/**
* The class constructor.
*/
function Smarty_Compiler()
public function __construct()
{
// matches double quoted strings:
// "foobar"
@@ -259,14 +258,9 @@ class Smarty_Compiler extends Smarty {
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. */
@@ -556,7 +550,7 @@ class Smarty_Compiler extends Smarty {
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 */
@@ -754,7 +748,12 @@ class Smarty_Compiler extends Smarty {
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
*
@@ -1192,7 +1191,7 @@ class Smarty_Compiler extends Smarty {
}
$output = '<?php ';
$output .= "\$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array'); }";
$output .= "\$_from = $from; if ((\$_from instanceof StdClass) || (!is_array(\$_from) && !is_object(\$_from))) { settype(\$_from, 'array'); }";
if (isset($name)) {
$foreach_props = "\$this->_foreach[$name]";
$output .= "{$foreach_props} = array('total' => count(\$_from), 'iteration' => 0);\n";
@@ -14,11 +14,9 @@
*/
function smarty_core_assemble_plugin_filepath($params, &$smarty)
{
static $_filepaths_cache = array();
$_plugin_filename = $params['type'] . '.' . $params['name'] . '.php';
if (isset($_filepaths_cache[$_plugin_filename])) {
return $_filepaths_cache[$_plugin_filename];
if (isset($smarty->_filepaths_cache[$_plugin_filename])) {
return $smarty->_filepaths_cache[$_plugin_filename];
}
$_return = false;
@@ -58,7 +56,7 @@ function smarty_core_assemble_plugin_filepath($params, &$smarty)
}
}
}
$_filepaths_cache[$_plugin_filename] = $_return;
$smarty->_filepaths_cache[$_plugin_filename] = $_return;
return $_return;
}
+68 -44
View File
@@ -1,85 +1,109 @@
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
* This plugin is only for Smarty2 BC
*
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {math} function plugin
*
* Type: function<br>
* Name: math<br>
* Purpose: handle math computations in template<br>
* @link http://smarty.php.net/manual/en/language.function.math.php {math}
* (Smarty online manual)
* Purpose: handle math computations in template
*
* @link http://www.smarty.net/manual/en/language.function.math.php {math}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param array
*
* @param array $params parameters
* @param Smarty
* @return string
*
* @return string|null
*/
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);
// be sure equation parameter is present
if (empty($params['equation'])) {
$smarty->trigger_error("math: missing equation parameter");
if (empty($params[ 'equation' ])) {
trigger_error("math: missing equation parameter", E_USER_WARNING);
return;
}
// strip out backticks, not necessary for math
$equation = str_replace('`','',$params['equation']);
$equation = $params[ 'equation' ];
// make sure parenthesis are balanced
if (substr_count($equation,"(") != substr_count($equation,")")) {
$smarty->trigger_error("math: unbalanced parenthesis");
if (substr_count($equation, "(") != substr_count($equation, ")")) {
trigger_error("math: unbalanced parenthesis", E_USER_WARNING);
return;
}
// disallow backticks
if (strpos($equation, '`') !== false) {
trigger_error("math: backtick character not allowed in equation", E_USER_WARNING);
return;
}
// also disallow dollar signs
if (strpos($equation, '$') !== false) {
trigger_error("math: dollar signs not allowed in equation", E_USER_WARNING);
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
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');
foreach($match[1] as $curr_var) {
if ($curr_var && !in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) {
$smarty->trigger_error("math: function call $curr_var not allowed");
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) {
if ($curr_var && !isset($params[ $curr_var ]) && !isset($_allowed_funcs[ $curr_var ])) {
trigger_error("math: function call '{$curr_var}' not allowed, or missing parameter '{$curr_var}'", E_USER_WARNING);
return;
}
}
foreach($params as $key => $val) {
foreach ($params as $key => $val) {
if ($key != "equation" && $key != "format" && $key != "assign") {
// make sure value is not empty
if (strlen($val)==0) {
$smarty->trigger_error("math: parameter $key is empty");
return;
}
if (!is_numeric($val)) {
$smarty->trigger_error("math: parameter $key: is not numeric");
return;
}
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
}
}
$smarty_math_result = null;
eval("\$smarty_math_result = " . $equation . ";");
eval("\$smarty_math_result = ".$equation.";");
if (empty($params['format'])) {
if (empty($params['assign'])) {
if (empty($params[ 'format' ])) {
if (empty($params[ 'assign' ])) {
return $smarty_math_result;
} else {
$smarty->assign($params['assign'],$smarty_math_result);
$smarty->assign($params[ 'assign' ], $smarty_math_result);
}
} else {
if (empty($params['assign'])){
printf($params['format'],$smarty_math_result);
if (empty($params[ 'assign' ])) {
printf($params[ 'format' ], $smarty_math_result);
} else {
$smarty->assign($params['assign'],sprintf($params['format'],$smarty_math_result));
$smarty->assign($params[ 'assign' ], sprintf($params[ 'format' ], $smarty_math_result));
}
}
}
/* vim: set expandtab: */
?>
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
if [[ "$1" =~ ^2\.[0-9\.-rc]+$ ]]; then
printf 'Creating release %s\n' "$1"
else
echo "Invalid version number: $1. This script can only make v2.x.x releases."
exit 1;
fi
git checkout -b "release/$1"
sed -i "s/=== Unreleased ===/=== Unreleased ===\\n\\n=== $1 - $(date +%Y-%m-%d) ===/" ChangeLog
sed -i "s/var \$_version = '[^']\+';/var \$_version = '$1';/" libs/Smarty.class.php
git add ChangeLog libs/Smarty.class.php
git commit -m "version bump"
git checkout support/2.6
git pull
git merge --no-ff "release/$1"
git branch -d "release/$1"
git tag -a "v$1" -m "Release $1"
printf 'Done creating release %s\n' "$1"
# shellcheck disable=SC2016
printf 'Run `git push --follow-tags origin` to publish it.\n'