From e75d2859c3877f2a156c5636fb0dcde8de1cb84a Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sun, 5 Jan 2025 14:42:03 +0700 Subject: [PATCH] Replaced some string functions to mbstring alternatives (#1735) * Replaced some string functions to mbstring alternatives * Update CHANGELOG.md * Update admin_attach_cp.php * Update CHANGELOG.md --- CHANGELOG.md | 1 + admin/admin_attach_cp.php | 6 +----- src/Legacy/WordsRate.php | 2 +- src/Validate.php | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 916e18bb8..c85b8b7bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Created `VersionHelper.php` [\#1731](https://github.com/torrentpier/torrentpier/pull/1731) ([belomaxorka](https://github.com/belomaxorka)) - Drop Ocelot announcer support 🫡 [\#1727](https://github.com/torrentpier/torrentpier/pull/1727) ([belomaxorka](https://github.com/belomaxorka)) - Use `DEFAULT_CHARSET` constant instead of hardcoded string [\#1734](https://github.com/torrentpier/torrentpier/pull/1734) ([belomaxorka](https://github.com/belomaxorka)) +- Replaced some string functions to `mbstring` alternatives [\#1735](https://github.com/torrentpier/torrentpier/pull/1735) ([belomaxorka](https://github.com/belomaxorka)) - Replaced some `html_entity_decode` to engine's built-in function [\#1733](https://github.com/torrentpier/torrentpier/pull/1733) ([belomaxorka](https://github.com/belomaxorka)) - Show torrent's announcers list in `filelist.php` page [\#1708](https://github.com/torrentpier/torrentpier/pull/1708) ([belomaxorka](https://github.com/belomaxorka)) - [PHP 8.4] Fixed some deprecations [\#1718](https://github.com/torrentpier/torrentpier/pull/1718) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/admin/admin_attach_cp.php b/admin/admin_attach_cp.php index 8dbb64787..eec2d557d 100644 --- a/admin/admin_attach_cp.php +++ b/admin/admin_attach_cp.php @@ -422,11 +422,7 @@ if ($view === 'attachments') { $row = DB()->sql_fetchrow($result); DB()->sql_freeresult($result); - $post_title = $row['topic_title']; - - if (strlen($post_title) > 32) { - $post_title = str_short($post_title, 30); - } + $post_title = str_short($row['topic_title'], 30); $view_topic = BB_ROOT . POST_URL . $ids[$j]['post_id'] . '#' . $ids[$j]['post_id']; diff --git a/src/Legacy/WordsRate.php b/src/Legacy/WordsRate.php index aeaaf2954..2cce058b7 100644 --- a/src/Legacy/WordsRate.php +++ b/src/Legacy/WordsRate.php @@ -46,7 +46,7 @@ class WordsRate $this->del_text_hl = $text; // Long text - if (strlen($text) > 600) { + if (mb_strlen($text, DEFAULT_CHARSET) > 600) { return $this->words_rate; } // Crop quotes if contains +1 diff --git a/src/Validate.php b/src/Validate.php index 7f4e03380..09de8e6e3 100644 --- a/src/Validate.php +++ b/src/Validate.php @@ -112,7 +112,7 @@ class Validate } // Check max length - if (\strlen($email) > USEREMAIL_MAX_LENGTH) { + if (mb_strlen($email, DEFAULT_CHARSET) > USEREMAIL_MAX_LENGTH) { return $lang['EMAIL_TOO_LONG']; }