From ffc1a4c5523c581210f94444e5581b1ff047cf74 Mon Sep 17 00:00:00 2001 From: Bugo Date: Sun, 14 Jan 2024 21:29:32 +0500 Subject: [PATCH] [2.1] Fix an issue where ban name length is not checked Signed-off-by: Bugo --- Sources/ManageBans.php | 4 ++++ Themes/default/ManageBans.template.php | 4 ++-- Themes/default/languages/Errors.english.php | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Sources/ManageBans.php b/Sources/ManageBans.php index ad3d16445a..7cb3370e8c 100644 --- a/Sources/ManageBans.php +++ b/Sources/ManageBans.php @@ -1498,6 +1498,8 @@ function updateBanGroup($ban_info = array()) if (empty($ban_info['name'])) $context['ban_errors'][] = 'ban_name_empty'; + if ($smcFunc['strlen']($ban_info['name']) > 20) + $context['ban_errors'][] = 'ban_name_is_too_long'; if (empty($ban_info['id'])) $context['ban_errors'][] = 'ban_id_empty'; if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) @@ -1587,6 +1589,8 @@ function insertBanGroup($ban_info = array()) if (empty($ban_info['name'])) $context['ban_errors'][] = 'ban_name_empty'; + if ($smcFunc['strlen']($ban_info['name']) > 20) + $context['ban_errors'][] = 'ban_name_is_too_long'; if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) $context['ban_errors'][] = 'ban_unknown_restriction_type'; diff --git a/Themes/default/ManageBans.template.php b/Themes/default/ManageBans.template.php index 9b179dfff3..172e125f77 100644 --- a/Themes/default/ManageBans.template.php +++ b/Themes/default/ManageBans.template.php @@ -56,7 +56,7 @@ function template_ban_edit() ', $txt['ban_name'], ':
- +
'; if (isset($context['ban']['reason'])) @@ -184,7 +184,7 @@ function template_ban_edit() '; - if (!$context['ban']['is_new'] && empty($context['ban_suggestions'])) + if (!$context['ban']['is_new'] && empty($context['ban_suggestions']) && !empty($context['ban_list'])) { echo '
'; diff --git a/Themes/default/languages/Errors.english.php b/Themes/default/languages/Errors.english.php index 6bfbbee05c..05ccef1345 100644 --- a/Themes/default/languages/Errors.english.php +++ b/Themes/default/languages/Errors.english.php @@ -188,6 +188,7 @@ $txt['ban_not_found'] = 'Ban not found'; $txt['ban_unknown_restriction_type'] = 'Restriction type unknown'; $txt['ban_name_empty'] = 'The name of the ban was left empty'; +$txt['ban_name_is_too_long'] = 'The selected name is too long. Use no more than 20 characters.'; $txt['ban_id_empty'] = 'Ban id not found'; $txt['ban_no_triggers'] = 'No ban triggers specified'; $txt['ban_ban_item_empty'] = 'Ban trigger not found';