Merge branch 'master' into smarty5

This commit is contained in:
Simon Wisselink
2023-01-24 12:53:58 +01:00
15 changed files with 8 additions and 48 deletions

View File

@@ -21,7 +21,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `$smarty->muteUndefinedOrNullWarnings()` now also mutes PHP7 notices for undefined array indexes [#736](https://github.com/smarty-php/smarty/issues/736) - `$smarty->muteUndefinedOrNullWarnings()` now also mutes PHP7 notices for undefined array indexes [#736](https://github.com/smarty-php/smarty/issues/736)
- `$smarty->muteUndefinedOrNullWarnings()` now treats undefined vars and array access of a null or false variables - `$smarty->muteUndefinedOrNullWarnings()` now treats undefined vars and array access of a null or false variables
equivalent across all supported PHP versions equivalent across all supported PHP versions
- `$smarty->muteUndefinedOrNullWarnings()` now allows dereferencing of non-objects accross all supported PHP versions [#831](https://github.com/smarty-php/smarty/issues/831) - `$smarty->muteUndefinedOrNullWarnings()` now allows dereferencing of non-objects across all supported PHP versions [#831](https://github.com/smarty-php/smarty/issues/831)
- PHP 8.1 deprecation warnings on null strings in modifiers [#834](https://github.com/smarty-php/smarty/pull/834)
## [4.3.0] - 2022-11-22 ## [4.3.0] - 2022-11-22
### Added ### Added
@@ -43,7 +45,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Adapt Smarty upper/lower functions to be codesafe (e.g. for Turkish locale) [#586](https://github.com/smarty-php/smarty/pull/586) - Adapt Smarty upper/lower functions to be codesafe (e.g. for Turkish locale) [#586](https://github.com/smarty-php/smarty/pull/586)
- Bug fix for underscore and limited length in template name in custom resources [#581](https://github.com/smarty-php/smarty/pull/581) - Bug fix for underscore and limited length in template name in custom resources [#581](https://github.com/smarty-php/smarty/pull/581)
## [4.2.1] - 2022-09-14 ## [4.2.1] - 2022-09-14
### Security ### Security

View File

@@ -14,7 +14,7 @@ namespace Smarty\Compile\Modifier;
class LowerModifierCompiler extends Base { class LowerModifierCompiler extends Base {
public function compile($params, \Smarty\Compiler\Template $compiler) { public function compile($params, \Smarty\Compiler\Template $compiler) {
return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')'; return 'mb_strtolower((string) ' . $params[ 0 ] . ', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
} }
} }

View File

@@ -13,7 +13,7 @@ namespace Smarty\Compile\Modifier;
class UpperModifierCompiler extends Base { class UpperModifierCompiler extends Base {
public function compile($params, \Smarty\Compiler\Template $compiler) { public function compile($params, \Smarty\Compiler\Template $compiler) {
return 'mb_strtoupper(' . $params[ 0 ] . ' ?? \'\', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')'; return 'mb_strtoupper((string) ' . $params[ 0 ] . ' ?? \'\', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
} }
} }

View File

@@ -651,7 +651,7 @@ class DefaultExtension extends Base {
*/ */
public function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false) public function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false)
{ {
if ($length === 0) { if ($length === 0 || $string === null) {
return ''; return '';
} }
if (mb_strlen($string, \Smarty\Smarty::$_CHARSET) > $length) { if (mb_strlen($string, \Smarty\Smarty::$_CHARSET) > $length) {

View File

@@ -62,7 +62,7 @@ class TrimWhitespace implements \Smarty\Filter\FilterInterface {
} }
} }
$expressions = array(// replace multiple spaces between tags by a single space $expressions = array(// replace multiple spaces between tags by a single space
// can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements // can't remove them entirely, because that might break poorly implemented CSS display:inline-block elements
'#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2', '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2',
// remove spaces between attributes (but not in attribute values!) // remove spaces between attributes (but not in attribute values!)
'#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',

View File

@@ -183,7 +183,7 @@ function smarty_mb_str_replace($search, $replace, $subject, &$count = 0)
function smarty_function_escape_special_chars($string) function smarty_function_escape_special_chars($string)
{ {
if (!is_array($string)) { if (!is_array($string)) {
$string = htmlspecialchars($string, ENT_COMPAT, \Smarty\Smarty::$_CHARSET, false); $string = htmlspecialchars((string) $string, ENT_COMPAT, \Smarty\Smarty::$_CHARSET, false);
} }
return $string; return $string;
} }

View File

@@ -1,6 +0,0 @@
{function 'nocache1' default1='d1' default2='d2'}
default1={$default1}
default2={$default1 nocache}
p1={$p1}
p2={$p2 nocache}
{/function}

View File

@@ -1,4 +0,0 @@
Test 1
<br/>
{include 'test7.tpl' compile_id = 4}

View File

@@ -1,7 +0,0 @@
Test 1
<br/>
{include 'test7.tpl' compile_id = $id}
{include 'test6.tpl'}
{include file="test2.tpl"}
{include 'test6.tpl'}

View File

@@ -1,3 +0,0 @@
Test 2
<br/>
{include file="test3.tpl" compile_id=4}

View File

@@ -1,4 +0,0 @@
Test 3 {call name='f' nocache}
<br/>
{include file="test4.tpl" compile_id=9}
{include file="test5.tpl" cache_id="7"}

View File

@@ -1,3 +0,0 @@
Test 4
<br/>
{include file="test5.tpl" cache_id="7"}

View File

@@ -1,8 +0,0 @@
test 6
<br>
{function name='f'}
<br>
function f {$id} {$foo}
<br>
{/function}
<br> Time 6 = {$t6}<br>