diff options
| author | Adrien Poupa <adrien@poupa.net> | 2023-01-16 18:24:23 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-17 00:24:23 +0100 |
| commit | 5988116c8146d284d5d93495991a06197428b67b (patch) | |
| tree | 4a6e6411a9fe6144bd4636a58bc8ce64ca6ae9b6 /libs | |
| parent | 73ff8fd3d0ecc004121dbc5fc611dabf38c13f59 (diff) | |
| download | smarty-5988116c8146d284d5d93495991a06197428b67b.tar.gz smarty-5988116c8146d284d5d93495991a06197428b67b.tar.bz2 smarty-5988116c8146d284d5d93495991a06197428b67b.zip | |
PHP 8.1 deprecation warnings on null strings in modifiers (#834)
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/plugins/modifier.truncate.php | 2 | ||||
| -rw-r--r-- | libs/plugins/modifiercompiler.count_characters.php | 4 | ||||
| -rw-r--r-- | libs/plugins/modifiercompiler.count_words.php | 2 | ||||
| -rw-r--r-- | libs/plugins/modifiercompiler.lower.php | 4 | ||||
| -rw-r--r-- | libs/plugins/modifiercompiler.upper.php | 4 | ||||
| -rw-r--r-- | libs/plugins/outputfilter.trimwhitespace.php | 2 | ||||
| -rw-r--r-- | libs/plugins/shared.escape_special_chars.php | 2 | ||||
| -rw-r--r-- | libs/plugins/variablefilter.htmlspecialchars.php | 2 |
8 files changed, 11 insertions, 11 deletions
diff --git a/libs/plugins/modifier.truncate.php b/libs/plugins/modifier.truncate.php index 80dcdb53..d253e4a6 100644 --- a/libs/plugins/modifier.truncate.php +++ b/libs/plugins/modifier.truncate.php @@ -26,7 +26,7 @@ */ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false) { - if ($length === 0) { + if ($length === 0 || $string === null) { return ''; } if (Smarty::$_MBSTRING) { diff --git a/libs/plugins/modifiercompiler.count_characters.php b/libs/plugins/modifiercompiler.count_characters.php index b5d97e27..7798cabc 100644 --- a/libs/plugins/modifiercompiler.count_characters.php +++ b/libs/plugins/modifiercompiler.count_characters.php @@ -25,8 +25,8 @@ function smarty_modifiercompiler_count_characters($params) return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)'; } if (Smarty::$_MBSTRING) { - return 'mb_strlen(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; + return 'mb_strlen((string) ' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; } // no MBString fallback - return 'strlen(' . $params[ 0 ] . ')'; + return 'strlen((string) ' . $params[ 0 ] . ')'; } diff --git a/libs/plugins/modifiercompiler.count_words.php b/libs/plugins/modifiercompiler.count_words.php index cf2e5022..48a3daa1 100644 --- a/libs/plugins/modifiercompiler.count_words.php +++ b/libs/plugins/modifiercompiler.count_words.php @@ -27,5 +27,5 @@ function smarty_modifiercompiler_count_words($params) $params[ 0 ] . ', $tmp)'; } // no MBString fallback - return 'str_word_count(' . $params[ 0 ] . ')'; + return 'str_word_count((string) ' . $params[ 0 ] . ')'; } diff --git a/libs/plugins/modifiercompiler.lower.php b/libs/plugins/modifiercompiler.lower.php index ac9cc39d..4144e561 100644 --- a/libs/plugins/modifiercompiler.lower.php +++ b/libs/plugins/modifiercompiler.lower.php @@ -22,8 +22,8 @@ function smarty_modifiercompiler_lower($params) { if (Smarty::$_MBSTRING) { - return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; + return 'mb_strtolower((string) ' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; } // no MBString fallback - return 'strtolower(' . $params[ 0 ] . ')'; + return 'strtolower((string) ' . $params[ 0 ] . ')'; } diff --git a/libs/plugins/modifiercompiler.upper.php b/libs/plugins/modifiercompiler.upper.php index 31a90a05..96030518 100644 --- a/libs/plugins/modifiercompiler.upper.php +++ b/libs/plugins/modifiercompiler.upper.php @@ -21,8 +21,8 @@ function smarty_modifiercompiler_upper($params) { if (Smarty::$_MBSTRING) { - return 'mb_strtoupper(' . $params[ 0 ] . ' ?? \'\', \'' . addslashes(Smarty::$_CHARSET) . '\')'; + return 'mb_strtoupper((string) ' . $params[ 0 ] . ' ?? \'\', \'' . addslashes(Smarty::$_CHARSET) . '\')'; } // no MBString fallback - return 'strtoupper(' . $params[ 0 ] . ' ?? \'\')'; + return 'strtoupper((string) ' . $params[ 0 ] . ' ?? \'\')'; } diff --git a/libs/plugins/outputfilter.trimwhitespace.php b/libs/plugins/outputfilter.trimwhitespace.php index 2f747ad5..180cdd08 100644 --- a/libs/plugins/outputfilter.trimwhitespace.php +++ b/libs/plugins/outputfilter.trimwhitespace.php @@ -62,7 +62,7 @@ function smarty_outputfilter_trimwhitespace($source) } } $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', // remove spaces between attributes (but not in attribute values!) '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', diff --git a/libs/plugins/shared.escape_special_chars.php b/libs/plugins/shared.escape_special_chars.php index a204b092..355b02b5 100644 --- a/libs/plugins/shared.escape_special_chars.php +++ b/libs/plugins/shared.escape_special_chars.php @@ -20,7 +20,7 @@ function smarty_function_escape_special_chars($string) { if (!is_array($string)) { - $string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false); + $string = htmlspecialchars((string) $string, ENT_COMPAT, Smarty::$_CHARSET, false); } return $string; } diff --git a/libs/plugins/variablefilter.htmlspecialchars.php b/libs/plugins/variablefilter.htmlspecialchars.php index 3c85295d..2eb12d20 100644 --- a/libs/plugins/variablefilter.htmlspecialchars.php +++ b/libs/plugins/variablefilter.htmlspecialchars.php @@ -15,5 +15,5 @@ */ function smarty_variablefilter_htmlspecialchars($source, Smarty_Internal_Template $template) { - return htmlspecialchars($source, ENT_QUOTES, Smarty::$_CHARSET); + return htmlspecialchars((string) $source, ENT_QUOTES, Smarty::$_CHARSET); } |
