From 2694adbc27678be26ddfdef32d767813a716014b Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Sun, 9 Jun 2024 10:20:44 +0100 Subject: [PATCH] bump smarty to 4.5.3 (the smarty release is regarded as a security fix ( CVE-2024-35226 ). PostfixAdmin should not be vulnerable as it does not use the extends tag. --- lib/smarty/libs/Smarty.class.php | 7 +- lib/smarty/libs/debug.tpl | 4 +- lib/smarty/libs/plugins/function.math.php | 2 +- lib/smarty/libs/plugins/modifier.escape.php | 4 +- lib/smarty/libs/plugins/modifier.implode.php | 15 +++++ lib/smarty/libs/plugins/modifier.truncate.php | 2 +- .../modifiercompiler.count_characters.php | 4 +- .../plugins/modifiercompiler.count_words.php | 2 +- .../libs/plugins/modifiercompiler.escape.php | 4 +- .../plugins/modifiercompiler.json_encode.php | 11 ++++ .../libs/plugins/modifiercompiler.lower.php | 4 +- .../plugins/modifiercompiler.strip_tags.php | 2 +- .../libs/plugins/modifiercompiler.substr.php | 12 ++++ .../libs/plugins/modifiercompiler.upper.php | 4 +- .../plugins/outputfilter.trimwhitespace.php | 2 +- .../plugins/shared.escape_special_chars.php | 2 +- .../variablefilter.htmlspecialchars.php | 2 +- .../smarty_internal_compile_extends.php | 66 +------------------ ...arty_internal_compile_private_modifier.php | 8 ++- ...ernal_compile_private_print_expression.php | 2 +- .../libs/sysplugins/smarty_internal_debug.php | 9 ++- .../smarty_internal_errorhandler.php | 34 +++++++++- .../smarty_internal_templatecompilerbase.php | 37 +++++++++-- .../smarty_internal_templateparser.php | 3 + .../libs/sysplugins/smarty_security.php | 2 +- .../sysplugins/smarty_template_compiled.php | 2 +- lib/smarty/smarty_version | 4 +- 27 files changed, 145 insertions(+), 105 deletions(-) create mode 100644 lib/smarty/libs/plugins/modifier.implode.php create mode 100644 lib/smarty/libs/plugins/modifiercompiler.json_encode.php create mode 100644 lib/smarty/libs/plugins/modifiercompiler.substr.php diff --git a/lib/smarty/libs/Smarty.class.php b/lib/smarty/libs/Smarty.class.php index 5d2e3a4b..b285a99e 100644 --- a/lib/smarty/libs/Smarty.class.php +++ b/lib/smarty/libs/Smarty.class.php @@ -107,7 +107,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '4.3.0'; + const SMARTY_VERSION = '4.5.3'; /** * define variable scopes */ @@ -1386,8 +1386,7 @@ class Smarty extends Smarty_Internal_TemplateBase } /** - * Activates PHP7 compatibility mode: - * - converts E_WARNINGS for "undefined array key" and "trying to read property of null" errors to E_NOTICE + * Mutes errors for "undefined index", "undefined array key" and "trying to read property of null". * * @void */ @@ -1396,7 +1395,7 @@ class Smarty extends Smarty_Internal_TemplateBase } /** - * Indicates if PHP7 compatibility mode is set. + * Indicates if Smarty will mute errors for "undefined index", "undefined array key" and "trying to read property of null". * @bool */ public function isMutingUndefinedOrNullWarnings(): bool { diff --git a/lib/smarty/libs/debug.tpl b/lib/smarty/libs/debug.tpl index 4f82a582..cd932566 100644 --- a/lib/smarty/libs/debug.tpl +++ b/lib/smarty/libs/debug.tpl @@ -167,9 +167,7 @@ {/capture} diff --git a/lib/smarty/libs/plugins/function.math.php b/lib/smarty/libs/plugins/function.math.php index f9cf67fe..34912d23 100644 --- a/lib/smarty/libs/plugins/function.math.php +++ b/lib/smarty/libs/plugins/function.math.php @@ -67,7 +67,7 @@ function smarty_function_math($params, $template) $equation = preg_replace('/\s+/', '', $equation); // Adapted from https://www.php.net/manual/en/function.eval.php#107377 - $number = '(?:\d+(?:[,.]\d+)?|pi|π)'; // What is a number + $number = '-?(?:\d+(?:[,.]\d+)?|pi|π)'; // What is a number $functionsOrVars = '((?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))'; $operators = '[,+\/*\^%-]'; // Allowed math operators $regexp = '/^(('.$number.'|'.$functionsOrVars.'|('.$functionsOrVars.'\s*\((?1)*\)|\((?1)*\)))(?:'.$operators.'(?1))?)+$/'; diff --git a/lib/smarty/libs/plugins/modifier.escape.php b/lib/smarty/libs/plugins/modifier.escape.php index 11e44682..e168679c 100644 --- a/lib/smarty/libs/plugins/modifier.escape.php +++ b/lib/smarty/libs/plugins/modifier.escape.php @@ -115,7 +115,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $ // see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements '