Fixed: mb_strlen(): Passing null parameter (#1374)

* Fixed: mb_strlen(): Passing null parameter

* Update CHANGELOG.md

* Update functions.php
This commit is contained in:
Roman Kelesidis 2024-02-02 21:13:36 +07:00 committed by GitHub
commit 73eedb5c65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View file

@ -28,6 +28,7 @@
- Set response code in some cases [\#1319](https://github.com/torrentpier/torrentpier/pull/1319) ([belomaxorka](https://github.com/belomaxorka))
- Fixed `admin_terms.php` textarea reset in preview mode [\#1371](https://github.com/torrentpier/torrentpier/pull/1371) ([belomaxorka](https://github.com/belomaxorka))
- Fixed broken user dl status [\#1351](https://github.com/torrentpier/torrentpier/pull/1351) ([belomaxorka](https://github.com/belomaxorka))
- Fixed: mb_strlen(): Passing null parameter [\#1374](https://github.com/torrentpier/torrentpier/pull/1374) ([belomaxorka](https://github.com/belomaxorka))
- Fixed auth(): empty $f_access [\#1329](https://github.com/torrentpier/torrentpier/pull/1329) ([belomaxorka](https://github.com/belomaxorka))
- Fixed download counter for torrents [\#1346](https://github.com/torrentpier/torrentpier/pull/1346) ([belomaxorka](https://github.com/belomaxorka))
- Fixed HTTP 500 while cron running in server-side [\#1321](https://github.com/torrentpier/torrentpier/pull/1321) ([belomaxorka](https://github.com/belomaxorka))

View file

@ -774,7 +774,7 @@ function get_user_id($username)
function str_short($text, $max_length, $space = ' ')
{
if ($max_length && mb_strlen($text, 'UTF-8') > $max_length) {
if (!empty($max_length) && !empty($text) && (mb_strlen($text, 'UTF-8') > $max_length)) {
$text = mb_substr($text, 0, $max_length, 'UTF-8');
if ($last_space_pos = $max_length - (int)strpos(strrev($text), (string)$space)) {
@ -787,7 +787,7 @@ function str_short($text, $max_length, $space = ' ')
$text = preg_replace('!&#?(\w+)?;?(\w{1,5})?\.\.\.$!', '...', $text);
}
return $text;
return $text ?? '';
}
function wbr($text, $max_word_length = HTML_WBR_LENGTH)