Skip to content

Commit

Permalink
Merge pull request SimpleMachines#8020 from dragomano/manage_bans
Browse files Browse the repository at this point in the history
[2.1] Fix an issue where ban name length is not checked
  • Loading branch information
Sesquipedalian committed Feb 6, 2024
2 parents 98fe7e1 + ffc1a4c commit 7f22610
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Sources/ManageBans.php
Expand Up @@ -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']))
Expand Down Expand Up @@ -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';

Expand Down
4 changes: 2 additions & 2 deletions Themes/default/ManageBans.template.php
Expand Up @@ -56,7 +56,7 @@ function template_ban_edit()
<strong>', $txt['ban_name'], ':</strong>
</dt>
<dd>
<input type="text" id="ban_name" name="ban_name" value="', $context['ban']['name'], '" size="45" maxlength="60">
<input type="text" id="ban_name" name="ban_name" value="', $context['ban']['name'], '" size="20" maxlength="20">
</dd>';

if (isset($context['ban']['reason']))
Expand Down Expand Up @@ -184,7 +184,7 @@ function template_ban_edit()
</div><!-- .windowbg -->
</form>';

if (!$context['ban']['is_new'] && empty($context['ban_suggestions']))
if (!$context['ban']['is_new'] && empty($context['ban_suggestions']) && !empty($context['ban_list']))
{
echo '
<br>';
Expand Down
1 change: 1 addition & 0 deletions Themes/default/languages/Errors.english.php
Expand Up @@ -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';
Expand Down

0 comments on commit 7f22610

Please sign in to comment.