Fix long ban reasons breaking rolebans (#62408)

Fixes long ban reasons breaking rolebans by adding a max length to the ban reason and making sure that the roleban_delimiter is present on a roleban.
This commit is contained in:
adamsong
2021-10-31 18:30:40 -05:00
committed by GitHub
parent 00d62baa5b
commit c783acad14

View File

@@ -1,6 +1,8 @@
#define MAX_ADMINBANS_PER_ADMIN 1
#define MAX_ADMINBANS_PER_HEADMIN 3
#define MAX_REASON_LENGTH 600
//checks client ban cache or DB ban table if ckey is banned from one or more roles
//doesn't return any details, use only for if statements
/proc/is_banned_from(player_ckey, list/roles)
@@ -201,7 +203,7 @@
<div class='column'>
Reason
<br>
<textarea class='reason' name='reason'>[reason]</textarea>
<textarea class='reason' name='reason' maxlength='[MAX_REASON_LENGTH]'>[reason]</textarea>
</div>
</div>
"}
@@ -411,6 +413,8 @@
reason = href_list["reason"]
if(!reason)
error_state += "No reason was provided."
if(length(reason) > MAX_REASON_LENGTH)
error_state += "Reason cannot be more than [MAX_REASON_LENGTH] characters."
if(href_list["editid"])
edit_id = href_list["editid"]
if(href_list["mirroredit"])
@@ -445,10 +449,12 @@
roles_to_ban += "Server"
if("role")
href_list.Remove("Command", "Security", "Engineering", "Medical", "Science", "Supply", "Silicon", "Abstract", "Service", "Ghost and Other Roles", "Antagonist Positions") //remove the role banner hidden input values
if(href_list[href_list.len] == "roleban_delimiter")
var/delimiter_pos = href_list.Find("roleban_delimiter")
if(href_list.len == delimiter_pos)
error_state += "Role ban was selected but no roles to ban were selected."
else if(delimiter_pos == 0)
error_state += "roleban_delimiter not found in href. Report this to coders."
else
var/delimiter_pos = href_list.Find("roleban_delimiter")
href_list.Cut(1, delimiter_pos+1)//remove every list element before and including roleban_delimiter so we have a list of only the roles to ban
for(var/key in href_list) //flatten into a list of only unique keys
roles_to_ban |= key
@@ -1017,3 +1023,5 @@
is_admin = TRUE
if(kick_banned_players && (!is_admin || (is_admin && applies_to_admins)))
qdel(other_player_client)
#undef MAX_REASON_LENGTH