Audits tgui_input_text() for length issues (#86741)

Fixes #86784

## About The Pull Request

Although some of the issues found were a direct result from #86692
(c698196766), there was still 40% of
length-related issues that wouldn't be covered anyways that are fixed in
this PR. I.E.:

* Name inputs without `MAX_NAME_LEN`
* Desc inputs without `MAX_DESC_LEN`
* Plaque inputs without `MAX_PLAQUE_LEN`
* Some people just screwed up the arguments so it would prefill
something like "40" in the `default` var because they didn't name their
vars.

To help me audit I added a lot of `max_length` named arguments to help
people understand it better. I think it might be kinder to have a
wrapper that handles adding `MAX_MESSAGE_LEN` in a lot of these cases
but I think there is some reason for a coder to be cognitive about input
texts? Let me know what you think. I didn't update anything
admin-related from what I can recall, let me know if anything needs to
be unlimited again.
## Why It's Good For The Game

The change to `INFINITY` notwithstanding, there were still an abundance
of issues that we needed to check up on. A lot of these are filtered on
down the line but it is clear that there needs to be something to catch
these issues. Maybe we could lint to make `max_length` a mandatory
argument? I don't know if that's necessary at all but I think that the
limit should be set by the invoker due to the wide arrangement of cases
that this proc could be used in.

This could all be a big nothingburger if the aforementioned PR is
reverted but a big chunk of cases fixed in this PR need to be fixed
regardless of that since people could put in 1024 character names for
stuff like guardians (or more now with the change). Consider this
"revert agnostic".
## Changelog
🆑
fix: A lot of instances where you could fill in 1024-character names
(normal limit is 42) have been patched out, along with too-long plaque
names, too-long descriptions, and more.
/🆑
This commit is contained in:
san7890
2024-09-20 22:46:41 +00:00
committed by GitHub
parent 840e73b1a3
commit a4328ae1f9
86 changed files with 183 additions and 137 deletions
@@ -8,7 +8,7 @@
laws = list("")
/obj/item/ai_module/core/freeformcore/attack_self(mob/user)
var/targName = tgui_input_text(user, "Enter a new core law for the AI.", "Freeform Law Entry", laws[1], CONFIG_GET(number/max_law_len), TRUE)
var/targName = tgui_input_text(user, "Enter a new core law for the AI.", "Freeform Law Entry", laws[1], max_length = CONFIG_GET(number/max_law_len), multiline = TRUE)
if(!targName || !user.is_holding(src))
return
if(is_ic_filtered(targName))
@@ -37,7 +37,7 @@
if(!newpos || !user.is_holding(src) || !usr.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return
lawpos = newpos
var/targName = tgui_input_text(user, "Enter a new law for the AI.", "Freeform Law Entry", laws[1], CONFIG_GET(number/max_law_len), TRUE)
var/targName = tgui_input_text(user, "Enter a new law for the AI.", "Freeform Law Entry", laws[1], max_length = CONFIG_GET(number/max_law_len), multiline = TRUE)
if(!targName || !user.is_holding(src))
return
if(is_ic_filtered(targName))
@@ -58,7 +58,7 @@
var/subject = "human being"
/obj/item/ai_module/core/full/asimov/attack_self(mob/user as mob)
var/targName = tgui_input_text(user, "Enter a new subject that Asimov is concerned with.", "Asimov", subject, MAX_NAME_LEN)
var/targName = tgui_input_text(user, "Enter a new subject that Asimov is concerned with.", "Asimov", subject, max_length = MAX_NAME_LEN)
if(!targName || !user.is_holding(src))
return
subject = targName
@@ -73,7 +73,7 @@
var/subject = "human being"
/obj/item/ai_module/core/full/asimovpp/attack_self(mob/user)
var/target_name = tgui_input_text(user, "Enter a new subject that Asimov++ is concerned with.", "Asimov++", subject, MAX_NAME_LEN)
var/target_name = tgui_input_text(user, "Enter a new subject that Asimov++ is concerned with.", "Asimov++", subject, max_length = MAX_NAME_LEN)
if(!target_name || !user.is_holding(src))
return
laws.Cut()
+1 -1
View File
@@ -4,7 +4,7 @@
laws = list("")
/obj/item/ai_module/syndicate/attack_self(mob/user)
var/targName = tgui_input_text(user, "Enter a new law for the AI", "Freeform Law Entry", laws[1], CONFIG_GET(number/max_law_len), TRUE)
var/targName = tgui_input_text(user, "Enter a new law for the AI", "Freeform Law Entry", laws[1], max_length = CONFIG_GET(number/max_law_len), multiline = TRUE)
if(!targName || !user.is_holding(src))
return
if(is_ic_filtered(targName)) // not even the syndicate can uwu
@@ -27,7 +27,7 @@
lawpos = 4
/obj/item/ai_module/supplied/safeguard/attack_self(mob/user)
var/targName = tgui_input_text(user, "Subject to safeguard.", "Safeguard", user.name, MAX_NAME_LEN)
var/targName = tgui_input_text(user, "Subject to safeguard.", "Safeguard", user.name, max_length = MAX_NAME_LEN)
if(!targName || !user.is_holding(src))
return
targetName = targName
+1 -1
View File
@@ -25,7 +25,7 @@
laws = list("Only SUBJECT is human.")
/obj/item/ai_module/zeroth/onehuman/attack_self(mob/user)
var/targName = tgui_input_text(user, "Enter the subject who is the only human.", "One Human", user.real_name, MAX_NAME_LEN)
var/targName = tgui_input_text(user, "Enter the subject who is the only human.", "One Human", user.real_name, max_length = MAX_NAME_LEN)
if(!targName || !user.is_holding(src))
return
targetName = targName
+7 -6
View File
@@ -1699,8 +1699,9 @@
to_chat(user, span_notice("You successfully reset the ID card."))
return
///forge the ID if not forged.
var/input_name = tgui_input_text(user, "What name would you like to put on this card? Leave blank to randomise.", "Agent card name", registered_name ? registered_name : (ishuman(user) ? user.real_name : user.name), MAX_NAME_LEN, encode = FALSE)
///forge the ID if not forged.s
var/input_name = tgui_input_text(user, "What name would you like to put on this card? Leave blank to randomise.", "Agent card name", registered_name ? registered_name : (ishuman(user) ? user.real_name : user.name), max_length = MAX_NAME_LEN, encode = FALSE)
if(!after_input_check(user))
return TRUE
if(input_name)
@@ -1730,7 +1731,7 @@
if(!after_input_check(user))
return TRUE
var/target_occupation = tgui_input_text(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels.", "Agent card job assignment", assignment ? assignment : "Assistant", MAX_NAME_LEN)
var/target_occupation = tgui_input_text(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels.", "Agent card job assignment", assignment ? assignment : "Assistant", max_length = MAX_NAME_LEN)
if(!after_input_check(user))
return TRUE
@@ -1884,15 +1885,15 @@
return
switch(popup_input)
if("Name")
var/input_name = tgui_input_text(user, "What name would you like to put on this card?", "Cardboard card name", scribbled_name || (ishuman(user) ? user.real_name : user.name), MAX_NAME_LEN)
input_name = sanitize_name(input_name, allow_numbers = TRUE)
var/raw_input = tgui_input_text(user, "What name would you like to put on this card?", "Cardboard card name", scribbled_name || (ishuman(user) ? user.real_name : user.name), max_length = MAX_NAME_LEN)
var/input_name = sanitize_name(raw_input, allow_numbers = TRUE)
if(!after_input_check(user, item, input_name, scribbled_name))
return
scribbled_name = input_name
var/list/details = item.get_writing_implement_details()
details_colors[INDEX_NAME_COLOR] = details["color"] || COLOR_BLACK
if("Assignment")
var/input_assignment = tgui_input_text(user, "What assignment would you like to put on this card?", "Cardboard card job ssignment", scribbled_assignment || "Assistant", MAX_NAME_LEN)
var/input_assignment = tgui_input_text(user, "What assignment would you like to put on this card?", "Cardboard card job ssignment", scribbled_assignment || "Assistant", max_length = MAX_NAME_LEN)
if(!after_input_check(user, item, input_assignment, scribbled_assignment))
return
scribbled_assignment = sanitize(input_assignment)
+1 -1
View File
@@ -402,7 +402,7 @@
set_painting_tool_color(paint_color)
. = TRUE
if("enter_text")
var/txt = tgui_input_text(usr, "Choose what to write", "Scribbles", text_buffer)
var/txt = tgui_input_text(usr, "Choose what to write", "Scribbles", text_buffer, max_length = MAX_MESSAGE_LEN)
if(isnull(txt))
return
txt = crayon_text_strip(txt)
+1 -1
View File
@@ -153,7 +153,7 @@
/obj/item/toy/eightball/haunted/start_shaking(mob/user)
// notify ghosts that someone's shaking a haunted eightball
// and inform them of the message, (hopefully a yes/no question)
selected_message = tgui_input_text(user, "What is your question?", "Eightball") || initial(selected_message)
selected_message = tgui_input_text(user, "What is your question?", "Eightball", max_length = MAX_MESSAGE_LEN) || initial(selected_message)
if (!(src in user.held_items))
return FALSE
notify_ghosts(
@@ -48,7 +48,7 @@
return
if(params["implant_action"] == "warn")
var/warning = tgui_input_text(user, "What warning do you want to send to [imp_in.name]?", "Messaging")
var/warning = tgui_input_text(user, "What warning do you want to send to [imp_in.name]?", "Messaging", max_length = MAX_MESSAGE_LEN)
if(!warning || QDELETED(src) || QDELETED(user) || QDELETED(console) || isnull(imp_in))
return TRUE
if(!console.is_operational || !user.can_perform_action(console, NEED_DEXTERITY|ALLOW_SILICON_REACH))
+2 -2
View File
@@ -548,10 +548,10 @@
shady_mail.made_by_cached_name = user.mind.name
if(index == 1)
var/mail_name = tgui_input_text(user, "Enter mail title, or leave it blank", "Mail Counterfeiting")
var/mail_name = tgui_input_text(user, "Enter mail title, or leave it blank", "Mail Counterfeiting", max_length = MAX_LABEL_LEN)
if(!(src in user.contents))
return FALSE
if(reject_bad_text(mail_name, ascii_only = FALSE))
if(reject_bad_text(mail_name, max_length = MAX_LABEL_LEN, ascii_only = FALSE))
shady_mail.name = mail_name
else
shady_mail.name = mail_type
+1 -1
View File
@@ -90,7 +90,7 @@ GLOBAL_LIST_EMPTY(tcgcard_machine_radial_choices)
/obj/machinery/trading_card_holder/attack_hand_secondary(mob/user)
if(isnull(current_summon))
var/card_name = tgui_input_text(user, "Insert card name", "Blank Card Naming", "blank card", MAX_NAME_LEN)
var/card_name = tgui_input_text(user, "Insert card name", "Blank Card Naming", "blank card", max_length = MAX_NAME_LEN)
if(isnull(card_name) || !user.can_perform_action(src))
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
current_summon = new /obj/structure/trading_card_summon/blank(locate(x + summon_offset_x, y + summon_offset_y, z))
+1 -1
View File
@@ -1404,7 +1404,7 @@
//Add changing looks when i feel suicidal about making 20 inhands for these.
/obj/item/toy/dummy/attack_self(mob/user)
var/new_name = tgui_input_text(usr, "What would you like to name the dummy?", "Doll Name", doll_name, MAX_NAME_LEN)
var/new_name = tgui_input_text(usr, "What would you like to name the dummy?", "Doll Name", doll_name, max_length = MAX_NAME_LEN)
if(!new_name || !user.is_holding(src))
return
doll_name = new_name
@@ -830,14 +830,17 @@ GLOBAL_LIST_EMPTY(roundstart_station_closets)
var/name_set = FALSE
var/desc_set = FALSE
var/str = tgui_input_text(user, "Locker Name", "Locker Name")
if(!isnull(str))
name = str
var/input_name = tgui_input_text(user, "Locker Name", "Locker Name", max_length = MAX_NAME_LEN)
if(!isnull(input_name))
name = input_name
name_set = TRUE
str = tgui_input_text(user, "Locker Description", "Locker Description")
if(!isnull(str))
desc = str
var/input_desc = tgui_input_text(user, "Locker Description", "Locker Description", max_length = MAX_DESC_LEN)
if(!isnull(input_desc))
desc = input_desc
desc_set = TRUE
var/bit_flag = NONE
@@ -50,11 +50,11 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/detectiveboard, 32)
to_chat(user, "You already attaching evidence!")
return
attaching_evidence = TRUE
var/name = tgui_input_text(user, "Please enter the evidence name", "Detective's Board")
var/name = tgui_input_text(user, "Please enter the evidence name", "Detective's Board", max_length = MAX_NAME_LEN)
if(!name)
attaching_evidence = FALSE
return
var/desc = tgui_input_text(user, "Please enter the evidence description", "Detective's Board")
var/desc = tgui_input_text(user, "Please enter the evidence description", "Detective's Board", max_length = MAX_DESC_LEN)
if(!desc)
attaching_evidence = FALSE
return
@@ -146,7 +146,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/detectiveboard, 32)
if("add_case")
if(cases.len == MAX_CASES)
return FALSE
var/new_case = tgui_input_text(user, "Please enter the case name", "Detective's Board")
var/new_case = tgui_input_text(user, "Please enter the case name", "Detective's Board", max_length = MAX_NAME_LEN)
if(!new_case)
return FALSE
var/case_color = tgui_input_list(user, "Please choose case color", "Detective's Board", case_colors)
@@ -173,7 +173,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/detectiveboard, 32)
update_appearance(UPDATE_ICON)
return TRUE
if("rename_case")
var/new_name = tgui_input_text(user, "Please ender the case new name", "Detective's Board")
var/new_name = tgui_input_text(user, "Please enter the new name for the case", "Detective's Board", max_length = MAX_NAME_LEN)
if(new_name)
var/datum/case/case = locate(params["case_ref"]) in cases
case.name = new_name
+1 -1
View File
@@ -426,7 +426,7 @@
return
if("change_message")
if(showpiece && !holographic_showpiece)
var/new_trophy_message = tgui_input_text(usr, "Let's make history!", "Trophy Message", trophy_message, MAX_PLAQUE_LEN)
var/new_trophy_message = tgui_input_text(usr, "Let's make history!", "Trophy Message", trophy_message, max_length = MAX_PLAQUE_LEN)
if(!new_trophy_message)
return
trophy_message = new_trophy_message
@@ -83,7 +83,7 @@
/obj/structure/door_assembly/attackby(obj/item/W, mob/living/user, params)
if(IS_WRITING_UTENSIL(W) && !user.combat_mode)
var/t = tgui_input_text(user, "Enter the name for the door", "Airlock Renaming", created_name, MAX_NAME_LEN)
var/t = tgui_input_text(user, "Enter the name for the door", "Airlock Renaming", created_name, max_length = MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
@@ -88,7 +88,7 @@
var/namechoice = tgui_input_text(user, "Title this plaque. (e.g. 'Best HoP Award', 'Great Ashwalker War Memorial')", "Plaque Customization", max_length = MAX_NAME_LEN)
if(!namechoice)
return
var/descriptionchoice = tgui_input_text(user, "Engrave this plaque's text", "Plaque Customization")
var/descriptionchoice = tgui_input_text(user, "Engrave this plaque's text", "Plaque Customization", max_length = MAX_PLAQUE_LEN)
if(!descriptionchoice)
return
if(!Adjacent(user)) //Make sure user is adjacent still
@@ -161,7 +161,7 @@
var/namechoice = tgui_input_text(user, "Title this plaque. (e.g. 'Best HoP Award', 'Great Ashwalker War Memorial')", "Plaque Customization", max_length = MAX_NAME_LEN)
if(!namechoice)
return
var/descriptionchoice = tgui_input_text(user, "Engrave this plaque's text", "Plaque Customization")
var/descriptionchoice = tgui_input_text(user, "Engrave this plaque's text", "Plaque Customization", max_length = MAX_PLAQUE_LEN)
if(!descriptionchoice)
return
if(!Adjacent(user)) //Make sure user is adjacent still
+1 -1
View File
@@ -94,7 +94,7 @@
ui_interact(user)
/obj/structure/votebox/proc/set_description(mob/user)
var/new_description = tgui_input_text(user, "Enter a new description", "Vote Description", vote_description, multiline = TRUE)
var/new_description = tgui_input_text(user, "Enter a new description", "Vote Description", vote_description, multiline = TRUE, max_length = MAX_DESC_LEN)
if(new_description)
vote_description = new_description
@@ -252,7 +252,7 @@
ae.forceMove(drop_location())
else if(IS_WRITING_UTENSIL(W))
var/t = tgui_input_text(user, "Enter the name for the door", "Windoor Renaming", created_name, MAX_NAME_LEN)
var/t = tgui_input_text(user, "Enter the name for the door", "Windoor Renaming", created_name, max_length = MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)