From 96fe1b92681a492af215281ba2965343da9cb655 Mon Sep 17 00:00:00 2001 From: volas Date: Sat, 7 Mar 2015 13:05:41 +0300 Subject: [PATCH 1/5] sanitize() refactor: text.dm --- code/__HELPERS/text.dm | 287 +++++++++++++++-------------------------- 1 file changed, 104 insertions(+), 183 deletions(-) diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm index 27f5f98aa4..54ce601ac7 100644 --- a/code/__HELPERS/text.dm +++ b/code/__HELPERS/text.dm @@ -22,46 +22,103 @@ * Text sanitization */ -//Simply removes < and > and limits the length of the message -/proc/strip_html_simple(var/t,var/limit=MAX_MESSAGE_LEN) - var/list/strip_chars = list("<",">") - t = copytext(t,1,limit) - for(var/char in strip_chars) - var/index = findtext(t, char) - while(index) - t = copytext(t, 1, index) + copytext(t, index+1) - index = findtext(t, char) - return t +//Used for preprocessing entered text +/proc/sanitize(var/input, var/max_length = MAX_MESSAGE_LEN, var/encode = 1, var/trim = 1, var/extra = 1) + if(!input) + return -//Removes a few problematic characters -/proc/sanitize_simple(var/t,var/list/repl_chars = list("\n"="#","\t"="#")) - for(var/char in repl_chars) - replacetext(t, char, repl_chars[char]) - return t + if(max_length) + input = copytext(input,1,max_length) -/proc/readd_quotes(var/t) - var/list/repl_chars = list(""" = "\"") - for(var/char in repl_chars) - var/index = findtext(t, char) - while(index) - t = copytext(t, 1, index) + repl_chars[char] + copytext(t, index+5) - index = findtext(t, char) - return t + if(extra) + input = replace_characters(input, list("\n"=" ","\t"=" ")) -//Runs byond's sanitization proc along-side sanitize_simple -/proc/sanitize(var/t,var/list/repl_chars = null) - return html_encode(sanitize_simple(t,repl_chars)) + if(encode) + //In addition to processing html, html_encode removes byond formatting codes like "\red", "\i" and other. + //It is important to avoid double-encode text, it can "break" quotes and some other characters. + //Also, keep in mind that escaped characters don't work in the interface (window titles, lower left corner of the main window, etc.) + input = html_encode(input) + else + //If not need encode text, simply remove < and > + //note: we can also remove here byond formatting codes: 0xFF + next byte + input = replace_characters(input, list("<"=" ", ">"=" ")) -//Runs sanitize and strip_html_simple -//I believe strip_html_simple() is required to run first to prevent '<' from displaying as '<' after sanitize() calls byond's html_encode() -/proc/strip_html(var/t,var/limit=MAX_MESSAGE_LEN) - return copytext((sanitize(strip_html_simple(t))),1,limit) + if(trim) + //Maybe, we need trim text twice? Here and before copytext? + input = trim(input) -//Runs byond's sanitization proc along-side strip_html_simple -//I believe strip_html_simple() is required to run first to prevent '<' from displaying as '<' that html_encode() would cause -/proc/adminscrub(var/t,var/limit=MAX_MESSAGE_LEN) - return copytext((html_encode(strip_html_simple(t))),1,limit) + return input +//Run sanitize(), but remove <, >, " first to prevent displaying them as > < &34; in some places, after html_encode(). +//Best used for sanitize object names, window titles. +//If you have a problem with sanitize() in chat, when quotes and >, < are displayed as html entites - +//this is a problem of double-encode(when & becomes &), use sanitize() with encode=0, but not the sanitizeSafe()! +/proc/sanitizeSafe(var/input, var/max_length = MAX_MESSAGE_LEN, var/encode = 1, var/trim = 1, var/extra = 1) + return sanitize(replace_characters(input, list(">"=" ","<"=" ", "\""="'"), max_length, encode, trim, extra)) + +//Filters out undesirable characters from names +/proc/sanitizeName(var/input, var/max_length = MAX_NAME_LEN, var/allow_numbers = 0) + if(!input || length(input) > max_length) + return //Rejects the input if it is null or if it is longer then the max length allowed + + var/number_of_alphanumeric = 0 + var/last_char_group = 0 + var/output = "" + + for(var/i=1, i<=length(input), i++) + var/ascii_char = text2ascii(input,i) + switch(ascii_char) + // A .. Z + if(65 to 90) //Uppercase Letters + output += ascii2text(ascii_char) + number_of_alphanumeric++ + last_char_group = 4 + + // a .. z + if(97 to 122) //Lowercase Letters + if(last_char_group<2) output += ascii2text(ascii_char-32) //Force uppercase first character + else output += ascii2text(ascii_char) + number_of_alphanumeric++ + last_char_group = 4 + + // 0 .. 9 + if(48 to 57) //Numbers + if(!last_char_group) continue //suppress at start of string + if(!allow_numbers) continue + output += ascii2text(ascii_char) + number_of_alphanumeric++ + last_char_group = 3 + + // ' - . + if(39,45,46) //Common name punctuation + if(!last_char_group) continue + output += ascii2text(ascii_char) + last_char_group = 2 + + // ~ | @ : # $ % & * + + if(126,124,64,58,35,36,37,38,42,43) //Other symbols that we'll allow (mainly for AI) + if(!last_char_group) continue //suppress at start of string + if(!allow_numbers) continue + output += ascii2text(ascii_char) + last_char_group = 2 + + //Space + if(32) + if(last_char_group <= 1) continue //suppress double-spaces and spaces at start of string + output += ascii2text(ascii_char) + last_char_group = 1 + else + return + + if(number_of_alphanumeric < 2) return //protects against tiny names like "A" and also names like "' ' ' ' ' ' ' '" + + if(last_char_group == 1) + output = copytext(output,1,length(output)) //removes the last character (in this case a space) + + for(var/bad_name in list("space","floor","wall","r-wall","monkey","unknown","inactive ai")) //prevents these common metagamey names + if(cmptext(output,bad_name)) return //(not case sensitive) + + return output //Returns null if there is any bad text in the string /proc/reject_bad_text(var/text, var/max_length=512) @@ -76,97 +133,11 @@ else non_whitespace = 1 if(non_whitespace) return text //only accepts the text if it has some non-spaces -// Used to get a properly sanitized input, of max_length -/proc/stripped_input(var/mob/user, var/message = "", var/title = "", var/default = "", var/max_length=MAX_MESSAGE_LEN) - var/name = input(user, message, title, default) - return strip_html_properly(name, max_length) -// Used to get a trimmed, properly sanitized input, of max_length -/proc/trim_strip_input(var/mob/user, var/message = "", var/title = "", var/default = "", var/max_length=MAX_MESSAGE_LEN) - return trim(stripped_input(user, message, title, default, max_length)) +//Old variant. Haven't dared to replace in some places. +/proc/sanitize_old(var/t,var/list/repl_chars = list("\n"="#","\t"="#")) + return html_encode(replace_characters(t,repl_chars)) -//Filters out undesirable characters from names -/proc/reject_bad_name(var/t_in, var/allow_numbers=0, var/max_length=MAX_NAME_LEN) - if(!t_in || length(t_in) > max_length) - return //Rejects the input if it is null or if it is longer then the max length allowed - - var/number_of_alphanumeric = 0 - var/last_char_group = 0 - var/t_out = "" - - for(var/i=1, i<=length(t_in), i++) - var/ascii_char = text2ascii(t_in,i) - switch(ascii_char) - // A .. Z - if(65 to 90) //Uppercase Letters - t_out += ascii2text(ascii_char) - number_of_alphanumeric++ - last_char_group = 4 - - // a .. z - if(97 to 122) //Lowercase Letters - if(last_char_group<2) t_out += ascii2text(ascii_char-32) //Force uppercase first character - else t_out += ascii2text(ascii_char) - number_of_alphanumeric++ - last_char_group = 4 - - // 0 .. 9 - if(48 to 57) //Numbers - if(!last_char_group) continue //suppress at start of string - if(!allow_numbers) continue - t_out += ascii2text(ascii_char) - number_of_alphanumeric++ - last_char_group = 3 - - // ' - . - if(39,45,46) //Common name punctuation - if(!last_char_group) continue - t_out += ascii2text(ascii_char) - last_char_group = 2 - - // ~ | @ : # $ % & * + - if(126,124,64,58,35,36,37,38,42,43) //Other symbols that we'll allow (mainly for AI) - if(!last_char_group) continue //suppress at start of string - if(!allow_numbers) continue - t_out += ascii2text(ascii_char) - last_char_group = 2 - - //Space - if(32) - if(last_char_group <= 1) continue //suppress double-spaces and spaces at start of string - t_out += ascii2text(ascii_char) - last_char_group = 1 - else - return - - if(number_of_alphanumeric < 2) return //protects against tiny names like "A" and also names like "' ' ' ' ' ' ' '" - - if(last_char_group == 1) - t_out = copytext(t_out,1,length(t_out)) //removes the last character (in this case a space) - - for(var/bad_name in list("space","floor","wall","r-wall","monkey","unknown","inactive ai")) //prevents these common metagamey names - if(cmptext(t_out,bad_name)) return //(not case sensitive) - - return t_out - -//checks text for html tags -//if tag is not in whitelist (var/list/paper_tag_whitelist in global.dm) -//relpaces < with < -proc/checkhtml(var/t) - t = sanitize_simple(t, list("&#"=".")) - var/p = findtext(t,"<",1) - while (p) //going through all the tags - var/start = p++ - var/tag = copytext(t,p, p+1) - if (tag != "/") - while (reject_bad_text(copytext(t, p, p+1), 1)) - tag = copytext(t,start, p) - p++ - tag = copytext(t,start+1, p) - if (!(tag in paper_tag_whitelist)) //if it's unkown tag, disarming it - t = copytext(t,1,start-1) + "<" + copytext(t,start+1) - p = findtext(t,"<",p) - return t /* * Text searches */ @@ -203,12 +174,18 @@ proc/checkhtml(var/t) /* * Text modification */ + /proc/replacetext(text, find, replacement) return list2text(text2list(text, find), replacement) /proc/replacetextEx(text, find, replacement) return list2text(text2listEx(text, find), replacement) +/proc/replace_characters(var/t,var/list/repl_chars) + for(var/char in repl_chars) + replacetext(t, char, repl_chars[char]) + return t + //Adds 'u' number of zeros ahead of the text 't' /proc/add_zero(t, u) while (length(t) < u) @@ -239,7 +216,6 @@ proc/checkhtml(var/t) for (var/i = length(text), i > 0, i--) if (text2ascii(text, i) > 32) return copytext(text, 1, i + 1) - return "" //Returns a string with reserved characters and spaces before the first word and after the last word removed. @@ -250,43 +226,18 @@ proc/checkhtml(var/t) /proc/capitalize(var/t as text) return uppertext(copytext(t, 1, 2)) + copytext(t, 2) -//Centers text by adding spaces to either side of the string. -/proc/dd_centertext(message, length) - var/new_message = message - var/size = length(message) - var/delta = length - size - if(size == length) - return new_message - if(size > length) - return copytext(new_message, 1, length + 1) - if(delta == 1) - return new_message + " " - if(delta % 2) - new_message = " " + new_message - delta-- - var/spaces = add_lspace("",delta/2-1) - return spaces + new_message + spaces - -//Limits the length of the text. Note: MAX_MESSAGE_LEN and MAX_NAME_LEN are widely used for this purpose -/proc/dd_limittext(message, length) - var/size = length(message) - if(size <= length) - return message - return copytext(message, 1, length + 1) - - -/proc/stringmerge(var/text,var/compare,replace = "*") //This proc fills in all spaces with the "replace" var (* by default) with whatever //is in the other string at the same spot (assuming it is not a replace char). //This is used for fingerprints +/proc/stringmerge(var/text,var/compare,replace = "*") var/newtext = text if(lentext(text) != lentext(compare)) return 0 for(var/i = 1, i < lentext(text), i++) var/a = copytext(text,i,i+1) var/b = copytext(compare,i,i+1) -//if it isn't both the same letter, or if they are both the replacement character -//(no way to know what it was supposed to be) + //if it isn't both the same letter, or if they are both the replacement character + //(no way to know what it was supposed to be) if(a != b) if(a == replace) //if A is the replacement char newtext = copytext(newtext,1,i) + b + copytext(newtext, i+1) @@ -296,9 +247,9 @@ proc/checkhtml(var/t) return 0 return newtext -/proc/stringpercent(var/text,character = "*") //This proc returns the number of chars of the string that is the character //This is used for detective work to determine fingerprint completion. +/proc/stringpercent(var/text,character = "*") if(!text || !character) return 0 var/count = 0 @@ -325,36 +276,6 @@ proc/TextPreview(var/string,var/len=40) else return "[copytext(string, 1, 37)]..." -//This proc strips html properly, but it's not lazy like the other procs. -//This means that it doesn't just remove < and > and call it a day. -//Also limit the size of the input, if specified. -/proc/strip_html_properly(var/input, var/max_length = MAX_MESSAGE_LEN) - if(!input) - return - var/opentag = 1 //These store the position of < and > respectively. - var/closetag = 1 - while(1) - opentag = findtext(input, "<") - closetag = findtext(input, ">") - if(closetag && opentag) - if(closetag < opentag) - input = copytext(input, (closetag + 1)) - else - input = copytext(input, 1, opentag) + copytext(input, (closetag + 1)) - else if(closetag || opentag) - if(opentag) - input = copytext(input, 1, opentag) - else - input = copytext(input, (closetag + 1)) - else - break - if(max_length) - input = copytext(input,1,max_length) - return sanitize(input) - -/proc/trim_strip_html_properly(var/input, var/max_length = MAX_MESSAGE_LEN) - return trim(strip_html_properly(input, max_length)) - //For generating neat chat tag-images //The icon var could be local in the proc, but it's a waste of resources // to always create it and then throw it out. From 855755f80887d48e199b72614ce81957026f336b Mon Sep 17 00:00:00 2001 From: volas Date: Sun, 22 Mar 2015 23:31:19 +0300 Subject: [PATCH 2/5] sanitize() refactor: first pass (sanitize) --- code/__HELPERS/lists.dm | 4 +-- code/datums/datumvars.dm | 4 +-- code/datums/mind.dm | 4 +-- code/game/antagonist/antagonist_build.dm | 2 +- code/game/dna/dna_modifier.dm | 2 +- code/game/gamemodes/objective.dm | 2 +- code/game/jobs/job/civilian_chaplain.dm | 4 +-- code/game/machinery/bots/farmbot.dm | 2 +- code/game/machinery/bots/mulebot.dm | 2 +- code/game/machinery/camera/tracking.dm | 2 +- code/game/machinery/computer/card.dm | 2 +- .../game/machinery/computer/communications.dm | 4 +-- code/game/machinery/computer/medical.dm | 28 +++++++++---------- code/game/machinery/computer/message.dm | 2 +- code/game/machinery/computer/prisoner.dm | 2 +- code/game/machinery/computer/security.dm | 18 ++++++------ code/game/machinery/computer/skills.dm | 6 ++-- code/game/machinery/computer/supply.dm | 4 +-- .../machinery/computer3/computers/card.dm | 2 +- .../computer3/computers/communications.dm | 4 +-- .../machinery/computer3/computers/medical.dm | 28 +++++++++---------- .../machinery/computer3/computers/prisoner.dm | 2 +- .../machinery/computer3/computers/security.dm | 16 +++++------ code/game/machinery/magnet.dm | 2 +- code/game/machinery/navbeacon.dm | 2 +- code/game/machinery/newscaster.dm | 2 +- code/game/machinery/portable_turret.dm | 2 +- code/game/objects/items/bodybag.dm | 2 +- code/game/objects/items/devices/PDA/PDA.dm | 6 ++-- code/game/objects/items/devices/PDA/cart.dm | 4 +-- code/game/objects/items/devices/megaphone.dm | 2 +- code/game/objects/items/devices/paicard.dm | 2 +- code/game/objects/items/weapons/AI_modules.dm | 2 +- code/game/objects/items/weapons/cards_ids.dm | 6 ++-- .../items/weapons/implants/implantcase.dm | 2 +- code/game/objects/structures/morgue.dm | 4 +-- code/game/verbs/ooc.dm | 4 +-- code/modules/admin/verbs/adminhelp.dm | 4 +-- code/modules/admin/verbs/adminpm.dm | 2 +- code/modules/admin/verbs/adminsay.dm | 4 +-- code/modules/admin/verbs/antag-ooc.dm | 2 +- code/modules/admin/verbs/deadsay.dm | 2 +- code/modules/admin/verbs/pray.dm | 6 ++-- code/modules/admin/verbs/striketeam.dm | 2 +- code/modules/client/preferences.dm | 10 +++---- code/modules/clothing/masks/voice.dm | 2 +- .../spacesuits/rig/modules/utility.dm | 4 +-- code/modules/library/lib_items.dm | 2 +- code/modules/library/lib_machines.dm | 8 +++--- code/modules/mob/emote.dm | 4 +-- code/modules/mob/living/carbon/brain/say.dm | 2 +- code/modules/mob/living/carbon/human/emote.dm | 4 +-- code/modules/mob/living/carbon/human/human.dm | 4 +-- .../mob/living/carbon/human/human_powers.dm | 4 +-- .../mob/living/carbon/metroid/items.dm | 4 +-- .../modules/mob/living/silicon/pai/recruit.dm | 16 +++++------ code/modules/mob/living/silicon/silicon.dm | 4 +-- code/modules/mob/mob_helpers.dm | 6 ++-- code/modules/paperwork/folders.dm | 2 +- code/modules/paperwork/paper.dm | 2 +- code/modules/paperwork/paper_bundle.dm | 2 +- code/modules/paperwork/photography.dm | 4 +-- code/modules/projectiles/ammunition.dm | 16 +++++------ code/modules/reagents/Chemistry-Machinery.dm | 2 +- .../reagents/reagent_containers/glass.dm | 2 +- code/modules/recycling/sortingmachinery.dm | 8 +++--- 66 files changed, 161 insertions(+), 161 deletions(-) diff --git a/code/__HELPERS/lists.dm b/code/__HELPERS/lists.dm index 75113338f3..b7caf86669 100644 --- a/code/__HELPERS/lists.dm +++ b/code/__HELPERS/lists.dm @@ -592,13 +592,13 @@ datum/proc/dd_SortValue() return "[src]" /obj/machinery/dd_SortValue() - return "[sanitize(name)]" + return "[sanitize_old(name)]" /obj/machinery/camera/dd_SortValue() return "[c_tag]" /datum/alarm/dd_SortValue() - return "[sanitize(last_name)]" + return "[sanitize_old(last_name)]" //creates every subtype of prototype (excluding prototype) and adds it to list L. //if no list/L is provided, one is created. diff --git a/code/datums/datumvars.dm b/code/datums/datumvars.dm index ad432cc22c..8daad7bfc1 100644 --- a/code/datums/datumvars.dm +++ b/code/datums/datumvars.dm @@ -427,7 +427,7 @@ client usr << "This can only be used on instances of type /mob" return - var/new_name = sanitize(copytext(input(usr,"What would you like to name this mob?","Input a name",M.real_name) as text|null,1,MAX_NAME_LEN)) + var/new_name = sanitize(input(usr,"What would you like to name this mob?","Input a name",M.real_name) as text|null, MAX_NAME_LEN) if( !new_name || !M ) return message_admins("Admin [key_name_admin(usr)] renamed [key_name_admin(M)] to [new_name].") @@ -875,7 +875,7 @@ client return if(organ_slot != "default") - organ_slot = sanitize(copytext(organ_slot,1,MAX_MESSAGE_LEN)) + organ_slot = sanitize(organ_slot) else if(I.removed_type) var/obj/item/organ/O = new I.removed_type() diff --git a/code/datums/mind.dm b/code/datums/mind.dm index 21881e281c..8906e22ca8 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -166,7 +166,7 @@ datum/mind assigned_role = new_role else if (href_list["memory_edit"]) - var/new_memo = sanitize(copytext(input("Write new memory", "Memory", memory) as null|message,1,MAX_MESSAGE_LEN)) + var/new_memo = sanitize(input("Write new memory", "Memory", memory) as null|message) if (isnull(new_memo)) return memory = new_memo @@ -277,7 +277,7 @@ datum/mind new_objective.target_amount = target_number if ("custom") - var/expl = sanitize(copytext(input("Custom objective:", "Objective", objective ? objective.explanation_text : "") as text|null,1,MAX_MESSAGE_LEN)) + var/expl = sanitize(input("Custom objective:", "Objective", objective ? objective.explanation_text : "") as text|null) if (!expl) return new_objective = new /datum/objective new_objective.owner = src diff --git a/code/game/antagonist/antagonist_build.dm b/code/game/antagonist/antagonist_build.dm index 6bf8f1e864..f0f92c62b7 100644 --- a/code/game/antagonist/antagonist_build.dm +++ b/code/game/antagonist/antagonist_build.dm @@ -52,7 +52,7 @@ // Choose a name, if any. if(flags & ANTAG_CHOOSE_NAME) spawn(5) - var/newname = sanitize(copytext(input(player.current, "You are a [role_text]. Would you like to change your name to something else?", "Name change") as null|text,1,MAX_NAME_LEN)) + var/newname = sanitize(input(player.current, "You are a [role_text]. Would you like to change your name to something else?", "Name change") as null|text, MAX_NAME_LEN) if (newname) player.current.real_name = newname player.current.name = player.current.real_name diff --git a/code/game/dna/dna_modifier.dm b/code/game/dna/dna_modifier.dm index 53086de252..e3c3a08a3a 100644 --- a/code/game/dna/dna_modifier.dm +++ b/code/game/dna/dna_modifier.dm @@ -737,7 +737,7 @@ if (bufferOption == "changeLabel") var/datum/dna2/record/buf = src.buffers[bufferId] - var/text = sanitize(copytext(input(usr, "New Label:", "Edit Label", buf.name) as text|null, 1, MAX_NAME_LEN)) + var/text = sanitize(input(usr, "New Label:", "Edit Label", buf.name) as text|null, MAX_NAME_LEN) buf.name = text src.buffers[bufferId] = buf return 1 diff --git a/code/game/gamemodes/objective.dm b/code/game/gamemodes/objective.dm index b6b638c578..f731cd024e 100644 --- a/code/game/gamemodes/objective.dm +++ b/code/game/gamemodes/objective.dm @@ -536,7 +536,7 @@ datum/objective/steal var/tmp_obj = new custom_target var/custom_name = tmp_obj:name del(tmp_obj) - custom_name = sanitize(copytext(input("Enter target name:", "Objective target", custom_name) as text|null,1,MAX_MESSAGE_LEN)) + custom_name = sanitize(input("Enter target name:", "Objective target", custom_name) as text|null) if (!custom_name) return target_name = custom_name steal_target = custom_target diff --git a/code/game/jobs/job/civilian_chaplain.dm b/code/game/jobs/job/civilian_chaplain.dm index 4131ec9b55..9b08e0d47c 100644 --- a/code/game/jobs/job/civilian_chaplain.dm +++ b/code/game/jobs/job/civilian_chaplain.dm @@ -28,7 +28,7 @@ H.equip_to_slot_or_del(new /obj/item/weapon/storage/box/survival(H.back), slot_in_backpack) spawn(0) var/religion_name = "Christianity" - var/new_religion = sanitize(copytext(input(H, "You are the crew services officer. Would you like to change your religion? Default is Christianity, in SPACE.", "Name change", religion_name),1,MAX_NAME_LEN)) + var/new_religion = sanitize(input(H, "You are the crew services officer. Would you like to change your religion? Default is Christianity, in SPACE.", "Name change", religion_name), MAX_NAME_LEN) if (!new_religion) new_religion = religion_name @@ -63,7 +63,7 @@ spawn(1) var/deity_name = "Space Jesus" - var/new_deity = sanitize(copytext(input(H, "Would you like to change your deity? Default is Space Jesus.", "Name change", deity_name),1,MAX_NAME_LEN)) + var/new_deity = sanitize(input(H, "Would you like to change your deity? Default is Space Jesus.", "Name change", deity_name), MAX_NAME_LEN) if ((length(new_deity) == 0) || (new_deity == "Space Jesus") ) new_deity = deity_name diff --git a/code/game/machinery/bots/farmbot.dm b/code/game/machinery/bots/farmbot.dm index 4db416e7a6..f91607eeb5 100644 --- a/code/game/machinery/bots/farmbot.dm +++ b/code/game/machinery/bots/farmbot.dm @@ -583,7 +583,7 @@ else if(istype(W, /obj/item/weapon/pen)) var/t = input(user, "Enter new robot name", src.name, src.created_name) as text - t = sanitize(copytext(t, 1, MAX_NAME_LEN)) + t = sanitize(t, MAX_NAME_LEN) if (!t) return if (!in_range(src, usr) && src.loc != usr) diff --git a/code/game/machinery/bots/mulebot.dm b/code/game/machinery/bots/mulebot.dm index 56f33676d5..bd39d2034c 100644 --- a/code/game/machinery/bots/mulebot.dm +++ b/code/game/machinery/bots/mulebot.dm @@ -307,7 +307,7 @@ if("setid") refresh=0 - var/new_id = sanitize(copytext(input("Enter new bot ID", "Mulebot [suffix ? "([suffix])" : ""]", suffix) as text|null,1,MAX_NAME_LEN)) + var/new_id = sanitize(input("Enter new bot ID", "Mulebot [suffix ? "([suffix])" : ""]", suffix) as text|null, MAX_NAME_LEN) refresh=1 if(new_id) suffix = new_id diff --git a/code/game/machinery/camera/tracking.dm b/code/game/machinery/camera/tracking.dm index 1b3619b5a4..186872117f 100644 --- a/code/game/machinery/camera/tracking.dm +++ b/code/game/machinery/camera/tracking.dm @@ -47,7 +47,7 @@ set name = "Store Camera Location" set desc = "Stores your current camera location by the given name" - loc = sanitize(copytext(loc, 1, MAX_MESSAGE_LEN)) + loc = sanitize(loc) if(!loc) src << "\red Must supply a location name" return diff --git a/code/game/machinery/computer/card.dm b/code/game/machinery/computer/card.dm index be5a73d90f..53a65f65e4 100644 --- a/code/game/machinery/computer/card.dm +++ b/code/game/machinery/computer/card.dm @@ -191,7 +191,7 @@ if (is_authenticated() && modify) var/t1 = href_list["assign_target"] if(t1 == "Custom") - var/temp_t = sanitize(copytext(input("Enter a custom job assignment.","Assignment"),1,45)) + var/temp_t = sanitize(input("Enter a custom job assignment.","Assignment"), 45) //let custom jobs function as an impromptu alt title, mainly for sechuds if(temp_t && modify) modify.assignment = temp_t diff --git a/code/game/machinery/computer/communications.dm b/code/game/machinery/computer/communications.dm index bc9f982477..c3e12d4a58 100644 --- a/code/game/machinery/computer/communications.dm +++ b/code/game/machinery/computer/communications.dm @@ -175,10 +175,10 @@ post_status(href_list["statdisp"]) if("setmsg1") - stat_msg1 = reject_bad_text(trim(sanitize(copytext(input("Line 1", "Enter Message Text", stat_msg1) as text|null, 1, 40))), 40) + stat_msg1 = reject_bad_text(sanitize(input("Line 1", "Enter Message Text", stat_msg1) as text|null, 40), 40) src.updateDialog() if("setmsg2") - stat_msg2 = reject_bad_text(trim(sanitize(copytext(input("Line 2", "Enter Message Text", stat_msg2) as text|null, 1, 40))), 40) + stat_msg2 = reject_bad_text(sanitize(input("Line 2", "Enter Message Text", stat_msg2) as text|null, 40), 40) src.updateDialog() // OMG CENTCOMM LETTERHEAD diff --git a/code/game/machinery/computer/medical.dm b/code/game/machinery/computer/medical.dm index 562b92a2df..c6a30995d2 100644 --- a/code/game/machinery/computer/medical.dm +++ b/code/game/machinery/computer/medical.dm @@ -250,7 +250,7 @@ switch(href_list["field"]) if("fingerprint") if (istype(src.active1, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input fingerprint hash:", "Med. records", src.active1.fields["fingerprint"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input fingerprint hash:", "Med. records", src.active1.fields["fingerprint"], null) as text) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || src.active1 != a1)) return src.active1.fields["fingerprint"] = t1 @@ -268,55 +268,55 @@ src.active1.fields["age"] = t1 if("mi_dis") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input minor disabilities list:", "Med. records", src.active2.fields["mi_dis"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input minor disabilities list:", "Med. records", src.active2.fields["mi_dis"], null) as text) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["mi_dis"] = t1 if("mi_dis_d") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please summarize minor dis.:", "Med. records", src.active2.fields["mi_dis_d"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize minor dis.:", "Med. records", src.active2.fields["mi_dis_d"], null) as message) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["mi_dis_d"] = t1 if("ma_dis") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input major diabilities list:", "Med. records", src.active2.fields["ma_dis"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input major diabilities list:", "Med. records", src.active2.fields["ma_dis"], null) as text) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["ma_dis"] = t1 if("ma_dis_d") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please summarize major dis.:", "Med. records", src.active2.fields["ma_dis_d"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize major dis.:", "Med. records", src.active2.fields["ma_dis_d"], null) as message) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["ma_dis_d"] = t1 if("alg") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please state allergies:", "Med. records", src.active2.fields["alg"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please state allergies:", "Med. records", src.active2.fields["alg"], null) as text) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["alg"] = t1 if("alg_d") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please summarize allergies:", "Med. records", src.active2.fields["alg_d"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize allergies:", "Med. records", src.active2.fields["alg_d"], null) as message) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["alg_d"] = t1 if("cdi") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please state diseases:", "Med. records", src.active2.fields["cdi"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please state diseases:", "Med. records", src.active2.fields["cdi"], null) as text) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["cdi"] = t1 if("cdi_d") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please summarize diseases:", "Med. records", src.active2.fields["cdi_d"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize diseases:", "Med. records", src.active2.fields["cdi_d"], null) as message) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["cdi_d"] = t1 if("notes") if (istype(src.active2, /datum/data/record)) - var/t1 = html_encode(trim(copytext(input("Please summarize notes:", "Med. records", html_decode(src.active2.fields["notes"]), null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize notes:", "Med. records", html_decode(src.active2.fields["notes"]), null) as message, extra = 0) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["notes"] = t1 @@ -331,21 +331,21 @@ src.temp = text("Blood Type:
\n\tA- A+
\n\tB- B+
\n\tAB- AB+
\n\tO- O+
", src, src, src, src, src, src, src, src) if("b_dna") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input DNA hash:", "Med. records", src.active2.fields["b_dna"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input DNA hash:", "Med. records", src.active2.fields["b_dna"], null) as text) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["b_dna"] = t1 if("vir_name") var/datum/data/record/v = locate(href_list["edit_vir"]) if (v) - var/t1 = trim(sanitize(copytext(input("Please input pathogen name:", "VirusDB", v.fields["name"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input pathogen name:", "VirusDB", v.fields["name"], null) as text) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || src.active1 != a1)) return v.fields["name"] = t1 if("vir_desc") var/datum/data/record/v = locate(href_list["edit_vir"]) if (v) - var/t1 = trim(sanitize(copytext(input("Please input information about pathogen:", "VirusDB", v.fields["description"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input information about pathogen:", "VirusDB", v.fields["description"], null) as message) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || src.active1 != a1)) return v.fields["description"] = t1 @@ -450,7 +450,7 @@ if (!( istype(src.active2, /datum/data/record) )) return var/a2 = src.active2 - var/t1 = trim(sanitize(copytext(input("Add Comment:", "Med. records", null, null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Add Comment:", "Med. records", null, null) as message) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return var/counter = 1 diff --git a/code/game/machinery/computer/message.dm b/code/game/machinery/computer/message.dm index bc7892b9bc..d11e606776 100644 --- a/code/game/machinery/computer/message.dm +++ b/code/game/machinery/computer/message.dm @@ -430,7 +430,7 @@ //Enter message if("Message") custommessage = input(usr, "Please enter your message.") as text|null - custommessage = sanitize(copytext(custommessage, 1, MAX_MESSAGE_LEN)) + custommessage = sanitize(custommessage) //Send message if("Send") diff --git a/code/game/machinery/computer/prisoner.dm b/code/game/machinery/computer/prisoner.dm index 00e7554727..976209305a 100644 --- a/code/game/machinery/computer/prisoner.dm +++ b/code/game/machinery/computer/prisoner.dm @@ -90,7 +90,7 @@ usr << "Unauthorized Access." else if(href_list["warn"]) - var/warning = sanitize(copytext(input(usr,"Message:","Enter your message here!",""),1,MAX_MESSAGE_LEN)) + var/warning = sanitize(input(usr,"Message:","Enter your message here!","")) if(!warning) return var/obj/item/weapon/implant/I = locate(href_list["warn"]) if((I)&&(I.imp_in)) diff --git a/code/game/machinery/computer/security.dm b/code/game/machinery/computer/security.dm index 5d5d995a41..1e4979b657 100644 --- a/code/game/machinery/computer/security.dm +++ b/code/game/machinery/computer/security.dm @@ -384,7 +384,7 @@ What a mess.*/ if (!( istype(active2, /datum/data/record) )) return var/a2 = active2 - var/t1 = trim(sanitize(copytext(input("Add Comment:", "Secure. records", null, null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Add Comment:", "Secure. records", null, null) as message) if ((!( t1 ) || !( authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || active2 != a2)) return var/counter = 1 @@ -432,13 +432,13 @@ What a mess.*/ active1.fields["name"] = t1 if("id") if (istype(active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input id:", "Secure. records", active1.fields["id"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input id:", "Secure. records", active1.fields["id"], null) as text) if (!t1 || active1 != a1) return active1.fields["id"] = t1 if("fingerprint") if (istype(active1, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input fingerprint hash:", "Secure. records", active1.fields["fingerprint"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input fingerprint hash:", "Secure. records", active1.fields["fingerprint"], null) as text) if (!t1 || active1 != a1) return active1.fields["fingerprint"] = t1 @@ -456,31 +456,31 @@ What a mess.*/ active1.fields["age"] = t1 if("mi_crim") if (istype(active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input minor disabilities list:", "Secure. records", active2.fields["mi_crim"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input minor disabilities list:", "Secure. records", active2.fields["mi_crim"], null) as text) if (!t1 || active2 != a2) return active2.fields["mi_crim"] = t1 if("mi_crim_d") if (istype(active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please summarize minor dis.:", "Secure. records", active2.fields["mi_crim_d"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize minor dis.:", "Secure. records", active2.fields["mi_crim_d"], null) as message) if (!t1 || active2 != a2) return active2.fields["mi_crim_d"] = t1 if("ma_crim") if (istype(active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input major diabilities list:", "Secure. records", active2.fields["ma_crim"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input major diabilities list:", "Secure. records", active2.fields["ma_crim"], null) as text) if (!t1 || active2 != a2) return active2.fields["ma_crim"] = t1 if("ma_crim_d") if (istype(active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please summarize major dis.:", "Secure. records", active2.fields["ma_crim_d"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize major dis.:", "Secure. records", active2.fields["ma_crim_d"], null) as message) if (!t1 || active2 != a2) return active2.fields["ma_crim_d"] = t1 if("notes") if (istype(active2, /datum/data/record)) - var/t1 = html_encode(trim(copytext(input("Please summarize notes:", "Secure. records", html_decode(active2.fields["notes"]), null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize notes:", "Secure. records", html_decode(active2.fields["notes"]), null) as message, extra = 0) if (!t1 || active2 != a2) return active2.fields["notes"] = t1 @@ -507,7 +507,7 @@ What a mess.*/ alert(usr, "You do not have the required rank to do this!") if("species") if (istype(active1, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please enter race:", "General records", active1.fields["species"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please enter race:", "General records", active1.fields["species"], null) as message) if (!t1 || active1 != a1) return active1.fields["species"] = t1 diff --git a/code/game/machinery/computer/skills.dm b/code/game/machinery/computer/skills.dm index 4d4997d23b..0c93c15bfc 100644 --- a/code/game/machinery/computer/skills.dm +++ b/code/game/machinery/computer/skills.dm @@ -315,13 +315,13 @@ What a mess.*/ active1.fields["name"] = t1 if("id") if (istype(active1, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input id:", "Secure. records", active1.fields["id"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input id:", "Secure. records", active1.fields["id"], null) as text) if ((!( t1 ) || !( authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || active1 != a1)) return active1.fields["id"] = t1 if("fingerprint") if (istype(active1, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input fingerprint hash:", "Secure. records", active1.fields["fingerprint"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input fingerprint hash:", "Secure. records", active1.fields["fingerprint"], null) as text) if ((!( t1 ) || !( authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || active1 != a1)) return active1.fields["fingerprint"] = t1 @@ -350,7 +350,7 @@ What a mess.*/ alert(usr, "You do not have the required rank to do this!") if("species") if (istype(active1, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please enter race:", "General records", active1.fields["species"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please enter race:", "General records", active1.fields["species"], null) as message) if ((!( t1 ) || !( authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon))) || active1 != a1)) return active1.fields["species"] = t1 diff --git a/code/game/machinery/computer/supply.dm b/code/game/machinery/computer/supply.dm index e27813ccf6..233a271108 100644 --- a/code/game/machinery/computer/supply.dm +++ b/code/game/machinery/computer/supply.dm @@ -85,7 +85,7 @@ if(!istype(P)) return var/timeout = world.time + 600 - var/reason = sanitize(copytext(input(usr,"Reason:","Why do you require this item?","") as null|text,1,MAX_MESSAGE_LEN)) + var/reason = sanitize(input(usr,"Reason:","Why do you require this item?","") as null|text) if(world.time > timeout) return if(!reason) return @@ -289,7 +289,7 @@ if(!istype(P)) return var/timeout = world.time + 600 - var/reason = sanitize(copytext(input(usr,"Reason:","Why do you require this item?","") as null|text,1,MAX_MESSAGE_LEN)) + var/reason = sanitize(input(usr,"Reason:","Why do you require this item?","") as null|text) if(world.time > timeout) return if(!reason) return diff --git a/code/game/machinery/computer3/computers/card.dm b/code/game/machinery/computer3/computers/card.dm index 963b1f4de7..3633252a46 100644 --- a/code/game/machinery/computer3/computers/card.dm +++ b/code/game/machinery/computer3/computers/card.dm @@ -304,7 +304,7 @@ if(auth) var/t1 = href_list["assign"] if(t1 == "Custom") - var/temp_t = sanitize(copytext(input("Enter a custom job assignment.","Assignment"),1,MAX_MESSAGE_LEN)) + var/temp_t = sanitize(input("Enter a custom job assignment.","Assignment")) if(temp_t) t1 = temp_t set_default_access(t1) diff --git a/code/game/machinery/computer3/computers/communications.dm b/code/game/machinery/computer3/computers/communications.dm index 527a2e2c5a..c8548bb933 100644 --- a/code/game/machinery/computer3/computers/communications.dm +++ b/code/game/machinery/computer3/computers/communications.dm @@ -178,10 +178,10 @@ post_status(href_list["statdisp"]) if("setmsg1" in href_list) - stat_msg1 = reject_bad_text(trim(sanitize(copytext(input("Line 1", "Enter Message Text", stat_msg1) as text|null, 1, 40)), 40)) + stat_msg1 = reject_bad_text(sanitize(input("Line 1", "Enter Message Text", stat_msg1) as text|null, 40), 40) computer.updateDialog() if("setmsg2" in href_list) - stat_msg2 = reject_bad_text(trim(sanitize(copytext(input("Line 2", "Enter Message Text", stat_msg2) as text|null, 1, 40)), 40)) + stat_msg2 = reject_bad_text(sanitize(input("Line 2", "Enter Message Text", stat_msg2) as text|null, 40), 40) computer.updateDialog() // OMG CENTCOMM LETTERHEAD diff --git a/code/game/machinery/computer3/computers/medical.dm b/code/game/machinery/computer3/computers/medical.dm index 42fcb9e5e7..96b1ccad5b 100644 --- a/code/game/machinery/computer3/computers/medical.dm +++ b/code/game/machinery/computer3/computers/medical.dm @@ -92,7 +92,7 @@ var/icon/side = active1.fields["photo_side"] usr << browse_rsc(front, "front.png") usr << browse_rsc(side, "side.png") - + dat += "
Name: [active1.fields["name"]] \ ID: [active1.fields["id"]]
\n \ Sex: [active1.fields["sex"]]
\n \ @@ -264,7 +264,7 @@ switch(href_list["field"]) if("fingerprint") if (istype(src.active1, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input fingerprint hash:", "Med. records", src.active1.fields["fingerprint"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input fingerprint hash:", "Med. records", src.active1.fields["fingerprint"], null) as text) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || src.active1 != a1)) return src.active1.fields["fingerprint"] = t1 @@ -282,49 +282,49 @@ src.active1.fields["age"] = t1 if("mi_dis") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input minor disabilities list:", "Med. records", src.active2.fields["mi_dis"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input minor disabilities list:", "Med. records", src.active2.fields["mi_dis"], null) as text) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["mi_dis"] = t1 if("mi_dis_d") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please summarize minor dis.:", "Med. records", src.active2.fields["mi_dis_d"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize minor dis.:", "Med. records", src.active2.fields["mi_dis_d"], null) as message) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["mi_dis_d"] = t1 if("ma_dis") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input major diabilities list:", "Med. records", src.active2.fields["ma_dis"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input major diabilities list:", "Med. records", src.active2.fields["ma_dis"], null) as text) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["ma_dis"] = t1 if("ma_dis_d") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please summarize major dis.:", "Med. records", src.active2.fields["ma_dis_d"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize major dis.:", "Med. records", src.active2.fields["ma_dis_d"], null) as message) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["ma_dis_d"] = t1 if("alg") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please state allergies:", "Med. records", src.active2.fields["alg"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please state allergies:", "Med. records", src.active2.fields["alg"], null) as text) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["alg"] = t1 if("alg_d") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please summarize allergies:", "Med. records", src.active2.fields["alg_d"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize allergies:", "Med. records", src.active2.fields["alg_d"], null) as message) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["alg_d"] = t1 if("cdi") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please state diseases:", "Med. records", src.active2.fields["cdi"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please state diseases:", "Med. records", src.active2.fields["cdi"], null) as text) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["cdi"] = t1 if("cdi_d") if (istype(src.active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please summarize diseases:", "Med. records", src.active2.fields["cdi_d"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize diseases:", "Med. records", src.active2.fields["cdi_d"], null) as message) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["cdi_d"] = t1 @@ -345,21 +345,21 @@ src.temp = text("Blood Type:
\n\tA- A+
\n\tB- B+
\n\tAB- AB+
\n\tO- O+
", src, src, src, src, src, src, src, src) if("b_dna") if (istype(src.active2, /datum/data/record)) - var/t1 = sanitize(copytext(trim(input("Please input DNA hash:", "Med. records", src.active2.fields["b_dna"], null) as text),1,MAX_MESSAGE_LEN)) + var/t1 = sanitize(input("Please input DNA hash:", "Med. records", src.active2.fields["b_dna"], null) as text) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["b_dna"] = t1 if("vir_name") var/datum/data/record/v = locate(href_list["edit_vir"]) if (v) - var/t1 = trim(sanitize(copytext(input("Please input pathogen name:", "VirusDB", v.fields["name"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input pathogen name:", "VirusDB", v.fields["name"], null) as text) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || src.active1 != a1)) return v.fields["name"] = t1 if("vir_desc") var/datum/data/record/v = locate(href_list["edit_vir"]) if (v) - var/t1 = trim(sanitize(copytext(input("Please input information about pathogen:", "VirusDB", v.fields["description"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input information about pathogen:", "VirusDB", v.fields["description"], null) as message) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || src.active1 != a1)) return v.fields["description"] = t1 @@ -464,7 +464,7 @@ if (!( istype(src.active2, /datum/data/record) )) return var/a2 = src.active2 - var/t1 = sanitize(copytext(input("Add Comment:", "Med. records", null, null) as message,1,MAX_MESSAGE_LEN)) + var/t1 = sanitize(input("Add Comment:", "Med. records", null, null) as message) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return var/counter = 1 diff --git a/code/game/machinery/computer3/computers/prisoner.dm b/code/game/machinery/computer3/computers/prisoner.dm index 7b0c97d4ae..49f1940d75 100644 --- a/code/game/machinery/computer3/computers/prisoner.dm +++ b/code/game/machinery/computer3/computers/prisoner.dm @@ -90,7 +90,7 @@ screen = !screen else if(href_list["warn"]) - var/warning = trim(sanitize(copytext(input(usr,"Message:","Enter your message here!",""),1,MAX_MESSAGE_LEN))) + var/warning = sanitize(input(usr,"Message:","Enter your message here!","")) if(!warning) return var/obj/item/weapon/implant/I = locate(href_list["warn"]) if( istype(I) && I.imp_in) diff --git a/code/game/machinery/computer3/computers/security.dm b/code/game/machinery/computer3/computers/security.dm index f630b24175..4c2f7369d2 100644 --- a/code/game/machinery/computer3/computers/security.dm +++ b/code/game/machinery/computer3/computers/security.dm @@ -404,7 +404,7 @@ What a mess.*/ if (!( istype(active2, /datum/data/record) )) return var/a2 = active2 - var/t1 = sanitize(copytext(input("Add Comment:", "Secure. records", null, null) as message,1,MAX_MESSAGE_LEN)) + var/t1 = sanitize(input("Add Comment:", "Secure. records", null, null) as message) if ((!( t1 ) || !( authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || active2 != a2)) return var/counter = 1 @@ -450,13 +450,13 @@ What a mess.*/ active1.fields["name"] = t1 if("id") if (istype(active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input id:", "Secure. records", active1.fields["id"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input id:", "Secure. records", active1.fields["id"], null) as text) if ((!( t1 ) || !( authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || active1 != a1)) return active1.fields["id"] = t1 if("fingerprint") if (istype(active1, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input fingerprint hash:", "Secure. records", active1.fields["fingerprint"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input fingerprint hash:", "Secure. records", active1.fields["fingerprint"], null) as text) if ((!( t1 ) || !( authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || active1 != a1)) return active1.fields["fingerprint"] = t1 @@ -474,25 +474,25 @@ What a mess.*/ active1.fields["age"] = t1 if("mi_crim") if (istype(active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input minor disabilities list:", "Secure. records", active2.fields["mi_crim"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input minor disabilities list:", "Secure. records", active2.fields["mi_crim"], null) as text) if ((!( t1 ) || !( authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || active2 != a2)) return active2.fields["mi_crim"] = t1 if("mi_crim_d") if (istype(active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please summarize minor dis.:", "Secure. records", active2.fields["mi_crim_d"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize minor dis.:", "Secure. records", active2.fields["mi_crim_d"], null) as message) if ((!( t1 ) || !( authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || active2 != a2)) return active2.fields["mi_crim_d"] = t1 if("ma_crim") if (istype(active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please input major diabilities list:", "Secure. records", active2.fields["ma_crim"], null) as text,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please input major diabilities list:", "Secure. records", active2.fields["ma_crim"], null) as text) if ((!( t1 ) || !( authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || active2 != a2)) return active2.fields["ma_crim"] = t1 if("ma_crim_d") if (istype(active2, /datum/data/record)) - var/t1 = trim(sanitize(copytext(input("Please summarize major dis.:", "Secure. records", active2.fields["ma_crim_d"], null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize major dis.:", "Secure. records", active2.fields["ma_crim_d"], null) as message) if ((!( t1 ) || !( authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || active2 != a2)) return active2.fields["ma_crim_d"] = t1 @@ -525,7 +525,7 @@ What a mess.*/ alert(usr, "You do not have the required rank to do this!") if("species") if (istype(active1, /datum/data/record)) - var/t1 = sanitize(copytext(input("Please enter race:", "General records", active1.fields["species"], null) as message,1,MAX_MESSAGE_LEN)) + var/t1 = sanitize(input("Please enter race:", "General records", active1.fields["species"], null) as message) if ((!( t1 ) || !( authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || active1 != a1)) return active1.fields["species"] = t1 diff --git a/code/game/machinery/magnet.dm b/code/game/machinery/magnet.dm index 8569ede3fd..b04e9d1851 100644 --- a/code/game/machinery/magnet.dm +++ b/code/game/machinery/magnet.dm @@ -323,7 +323,7 @@ if(speed <= 0) speed = 1 if("setpath") - var/newpath = sanitize(copytext(input(usr, "Please define a new path!",,path) as text|null,1,MAX_MESSAGE_LEN)) + var/newpath = sanitize(input(usr, "Please define a new path!",,path) as text|null) if(newpath && newpath != "") moving = 0 // stop moving path = newpath diff --git a/code/game/machinery/navbeacon.dm b/code/game/machinery/navbeacon.dm index 56fcd1298e..de2a13aab5 100644 --- a/code/game/machinery/navbeacon.dm +++ b/code/game/machinery/navbeacon.dm @@ -194,7 +194,7 @@ Transponder Codes:
    "} updateDialog() else if(href_list["locedit"]) - var/newloc = sanitize(copytext(input("Enter New Location", "Navigation Beacon", location) as text|null,1,MAX_MESSAGE_LEN)) + var/newloc = sanitize(input("Enter New Location", "Navigation Beacon", location) as text|null) if(newloc) location = newloc updateDialog() diff --git a/code/game/machinery/newscaster.dm b/code/game/machinery/newscaster.dm index 5c56690228..9f65c8235d 100644 --- a/code/game/machinery/newscaster.dm +++ b/code/game/machinery/newscaster.dm @@ -945,7 +945,7 @@ obj/item/weapon/newspaper/attackby(obj/item/weapon/W as obj, mob/user as mob) user << "There's already a scribble in this page... You wouldn't want to make things too cluttered, would you?" else var/s = strip_html( input(user, "Write something", "Newspaper", "") ) - s = sanitize(copytext(s, 1, MAX_MESSAGE_LEN)) + s = sanitize(s) if (!s) return if (!in_range(src, usr) && src.loc != usr) diff --git a/code/game/machinery/portable_turret.dm b/code/game/machinery/portable_turret.dm index a5f7bf0be0..deaebef39a 100644 --- a/code/game/machinery/portable_turret.dm +++ b/code/game/machinery/portable_turret.dm @@ -818,7 +818,7 @@ if(istype(I, /obj/item/weapon/pen)) //you can rename turrets like bots! var/t = input(user, "Enter new turret name", name, finish_name) as text - t = sanitize(copytext(t, 1, MAX_MESSAGE_LEN)) + t = sanitize(t) if(!t) return if(!in_range(src, usr) && loc != usr) diff --git a/code/game/objects/items/bodybag.dm b/code/game/objects/items/bodybag.dm index 5183170aa6..fcbebdba20 100644 --- a/code/game/objects/items/bodybag.dm +++ b/code/game/objects/items/bodybag.dm @@ -49,7 +49,7 @@ return if (!in_range(src, user) && src.loc != user) return - t = sanitize(copytext(t,1,MAX_MESSAGE_LEN)) + t = sanitize(t) if (t) src.name = "body bag - " src.name += t diff --git a/code/game/objects/items/devices/PDA/PDA.dm b/code/game/objects/items/devices/PDA/PDA.dm index 2825045fb2..0bc2139ae7 100755 --- a/code/game/objects/items/devices/PDA/PDA.dm +++ b/code/game/objects/items/devices/PDA/PDA.dm @@ -726,7 +726,7 @@ var/global/list/obj/item/device/pda/PDAs = list() U << "The PDA softly beeps." ui.close() else - t = sanitize(copytext(t, 1, 20)) + t = sanitize(t, 20) ttone = t else ui.close() @@ -735,7 +735,7 @@ var/global/list/obj/item/device/pda/PDAs = list() var/t = input(U, "Please enter new news tone", name, newstone) as text if (in_range(src, U) && loc == U) if (t) - t = sanitize(copytext(t, 1, 20)) + t = sanitize(t, 20) newstone = t else ui.close() @@ -971,7 +971,7 @@ var/global/list/obj/item/device/pda/PDAs = list() U.visible_message("[U] taps on \his PDA's screen.") U.last_target_click = world.time var/t = input(U, "Please enter message", P.name, null) as text - t = sanitize(copytext(t, 1, MAX_MESSAGE_LEN)) + t = sanitize(t) t = readd_quotes(t) if (!t || !istype(P)) return diff --git a/code/game/objects/items/devices/PDA/cart.dm b/code/game/objects/items/devices/PDA/cart.dm index 8c86a37ac0..5ab09d0853 100644 --- a/code/game/objects/items/devices/PDA/cart.dm +++ b/code/game/objects/items/devices/PDA/cart.dm @@ -562,10 +562,10 @@ if("alert") post_status("alert", href_list["alert"]) if("setmsg1") - message1 = reject_bad_text(trim(sanitize(copytext(input("Line 1", "Enter Message Text", message1) as text|null, 1, 40))), 40) + message1 = reject_bad_text(sanitize(input("Line 1", "Enter Message Text", message1) as text|null, 40), 40) updateSelfDialog() if("setmsg2") - message2 = reject_bad_text(trim(sanitize(copytext(input("Line 2", "Enter Message Text", message2) as text|null, 1, 40))), 40) + message2 = reject_bad_text(sanitize(input("Line 2", "Enter Message Text", message2) as text|null, 40), 40) updateSelfDialog() else post_status(href_list["statdisp"]) diff --git a/code/game/objects/items/devices/megaphone.dm b/code/game/objects/items/devices/megaphone.dm index 5bf49de055..53fac1be05 100644 --- a/code/game/objects/items/devices/megaphone.dm +++ b/code/game/objects/items/devices/megaphone.dm @@ -25,7 +25,7 @@ user << "\red \The [src] needs to recharge!" return - var/message = sanitize(copytext(input(user, "Shout a message?", "Megaphone", null) as text,1,MAX_MESSAGE_LEN)) + var/message = sanitize(input(user, "Shout a message?", "Megaphone", null) as text) if(!message) return message = capitalize(message) diff --git a/code/game/objects/items/devices/paicard.dm b/code/game/objects/items/devices/paicard.dm index d3c667b9aa..2cc9d55b6a 100644 --- a/code/game/objects/items/devices/paicard.dm +++ b/code/game/objects/items/devices/paicard.dm @@ -260,7 +260,7 @@ if(2) radio.ToggleReception() if(href_list["setlaws"]) - var/newlaws = sanitize(copytext(input("Enter any additional directives you would like your pAI personality to follow. Note that these directives will not override the personality's allegiance to its imprinted master. Conflicting directives will be ignored.", "pAI Directive Configuration", pai.pai_laws) as message,1,MAX_MESSAGE_LEN)) + var/newlaws = sanitize(input("Enter any additional directives you would like your pAI personality to follow. Note that these directives will not override the personality's allegiance to its imprinted master. Conflicting directives will be ignored.", "pAI Directive Configuration", pai.pai_laws) as message) if(newlaws) pai.pai_laws = newlaws pai << "Your supplemental directives have been updated. Your new directives are:" diff --git a/code/game/objects/items/weapons/AI_modules.dm b/code/game/objects/items/weapons/AI_modules.dm index e5c037eb12..9d47d2b08b 100755 --- a/code/game/objects/items/weapons/AI_modules.dm +++ b/code/game/objects/items/weapons/AI_modules.dm @@ -265,7 +265,7 @@ AI MODULES if(new_lawpos < MIN_SUPPLIED_LAW_NUMBER) return lawpos = min(new_lawpos, MAX_SUPPLIED_LAW_NUMBER) var/newlaw = "" - var/targName = sanitize(copytext(input(usr, "Please enter a new law for the AI.", "Freeform Law Entry", newlaw),1,MAX_MESSAGE_LEN)) + var/targName = sanitize(input(usr, "Please enter a new law for the AI.", "Freeform Law Entry", newlaw)) newFreeFormLaw = targName desc = "A 'freeform' AI module: ([lawpos]) '[newFreeFormLaw]'" diff --git a/code/game/objects/items/weapons/cards_ids.dm b/code/game/objects/items/weapons/cards_ids.dm index 3348ae6cdd..9ad9b23f75 100644 --- a/code/game/objects/items/weapons/cards_ids.dm +++ b/code/game/objects/items/weapons/cards_ids.dm @@ -230,7 +230,7 @@ return src.registered_name = t - var u = sanitize(copytext(input(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels other than Maintenance.", "Agent card job assignment", "Agent"),1,MAX_MESSAGE_LEN)) + var u = sanitize(input(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels other than Maintenance.", "Agent card job assignment", "Agent")) if(!u) alert("Invalid assignment.") src.registered_name = "" @@ -245,13 +245,13 @@ switch(alert("Would you like to display the ID, or retitle it?","Choose.","Rename","Show")) if("Rename") - var t = sanitize(copytext(input(user, "What name would you like to put on this card?", "Agent card name", ishuman(user) ? user.real_name : user.name),1,26)) + var t = sanitize(input(user, "What name would you like to put on this card?", "Agent card name", ishuman(user) ? user.real_name : user.name), 26) if(!t || t == "Unknown" || t == "floor" || t == "wall" || t == "r-wall") //Same as mob/new_player/prefrences.dm alert("Invalid name.") return src.registered_name = t - var u = sanitize(copytext(input(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels other than Maintenance.", "Agent card job assignment", "Assistant"),1,MAX_MESSAGE_LEN)) + var u = sanitize(input(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels other than Maintenance.", "Agent card job assignment", "Assistant")) if(!u) alert("Invalid assignment.") return diff --git a/code/game/objects/items/weapons/implants/implantcase.dm b/code/game/objects/items/weapons/implants/implantcase.dm index 00ce8a7950..ddb76b3656 100644 --- a/code/game/objects/items/weapons/implants/implantcase.dm +++ b/code/game/objects/items/weapons/implants/implantcase.dm @@ -26,7 +26,7 @@ return if((!in_range(src, usr) && src.loc != user)) return - t = sanitize(copytext(t,1,MAX_MESSAGE_LEN)) + t = sanitize(t) if(t) src.name = text("Glass Case - '[]'", t) else diff --git a/code/game/objects/structures/morgue.dm b/code/game/objects/structures/morgue.dm index 1a87fcede9..1f597b0c96 100644 --- a/code/game/objects/structures/morgue.dm +++ b/code/game/objects/structures/morgue.dm @@ -92,7 +92,7 @@ return if ((!in_range(src, usr) && src.loc != user)) return - t = sanitize(copytext(t,1,MAX_MESSAGE_LEN)) + t = sanitize(t) if (t) src.name = text("Morgue- '[]'", t) else @@ -258,7 +258,7 @@ return if ((!in_range(src, usr) > 1 && src.loc != user)) return - t = sanitize(copytext(t,1,MAX_MESSAGE_LEN)) + t = sanitize(t) if (t) src.name = text("Crematorium- '[]'", t) else diff --git a/code/game/verbs/ooc.dm b/code/game/verbs/ooc.dm index b8c124dcd8..92b0638b9f 100644 --- a/code/game/verbs/ooc.dm +++ b/code/game/verbs/ooc.dm @@ -12,7 +12,7 @@ src << "Guests may not use OOC." return - msg = trim(sanitize(copytext(msg, 1, MAX_MESSAGE_LEN))) + msg = sanitize(msg) if(!msg) return if(!(prefs.toggles & CHAT_OOC)) @@ -77,7 +77,7 @@ src << "Guests may not use OOC." return - msg = trim(sanitize(copytext(msg, 1, MAX_MESSAGE_LEN))) + msg = sanitize(msg) if(!msg) return if(!(prefs.toggles & CHAT_LOOC)) diff --git a/code/modules/admin/verbs/adminhelp.dm b/code/modules/admin/verbs/adminhelp.dm index bff2372aa9..9f29bc621a 100644 --- a/code/modules/admin/verbs/adminhelp.dm +++ b/code/modules/admin/verbs/adminhelp.dm @@ -23,7 +23,7 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey"," //clean the input msg if(!msg) return - msg = sanitize(copytext(msg,1,MAX_MESSAGE_LEN)) + msg = sanitize(msg) if(!msg) return var/original_msg = msg @@ -88,7 +88,7 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey"," if(ai_found) ai_cl = " (CL)" - //Options bar: mob, details ( admin = 2, dev = 3, mentor = 4, character name (0 = just ckey, 1 = ckey and character name), link? (0 no don't make it a link, 1 do so), + //Options bar: mob, details ( admin = 2, dev = 3, mentor = 4, character name (0 = just ckey, 1 = ckey and character name), link? (0 no don't make it a link, 1 do so), // highlight special roles (0 = everyone has same looking name, 1 = antags / special roles get a golden name) var/mentor_msg = "\blue Request for Help: [get_options_bar(mob, 4, 1, 1, 0)][ai_cl]: [msg]" diff --git a/code/modules/admin/verbs/adminpm.dm b/code/modules/admin/verbs/adminpm.dm index 1c358c8cf4..9d13437faa 100644 --- a/code/modules/admin/verbs/adminpm.dm +++ b/code/modules/admin/verbs/adminpm.dm @@ -61,7 +61,7 @@ //clean the message if it's not sent by a high-rank admin if(!check_rights(R_SERVER|R_DEBUG,0)) - msg = sanitize(copytext(msg,1,MAX_MESSAGE_LEN)) + msg = sanitize(msg) if(!msg) return var/recieve_pm_type = "Player" diff --git a/code/modules/admin/verbs/adminsay.dm b/code/modules/admin/verbs/adminsay.dm index e3aa767ecd..fdbbe8d4e1 100644 --- a/code/modules/admin/verbs/adminsay.dm +++ b/code/modules/admin/verbs/adminsay.dm @@ -4,7 +4,7 @@ set hidden = 1 if(!check_rights(R_ADMIN)) return - msg = sanitize(copytext(msg, 1, MAX_MESSAGE_LEN)) + msg = sanitize(msg) if(!msg) return log_admin("[key_name(src)] : [msg]") @@ -23,7 +23,7 @@ if(!check_rights(R_ADMIN|R_MOD|R_MENTOR)) return - msg = sanitize(copytext(msg, 1, MAX_MESSAGE_LEN)) + msg = sanitize(msg) log_admin("MOD: [key_name(src)] : [msg]") if (!msg) diff --git a/code/modules/admin/verbs/antag-ooc.dm b/code/modules/admin/verbs/antag-ooc.dm index 82e81c0595..53a2c709fc 100644 --- a/code/modules/admin/verbs/antag-ooc.dm +++ b/code/modules/admin/verbs/antag-ooc.dm @@ -5,7 +5,7 @@ if(!check_rights(R_ADMIN)) return - msg = sanitize(copytext(msg, 1, MAX_MESSAGE_LEN)) + msg = sanitize(msg) if(!msg) return var/display_name = src.key diff --git a/code/modules/admin/verbs/deadsay.dm b/code/modules/admin/verbs/deadsay.dm index bb66843c16..b3b6e3fdae 100644 --- a/code/modules/admin/verbs/deadsay.dm +++ b/code/modules/admin/verbs/deadsay.dm @@ -29,7 +29,7 @@ if (src.holder.rights & R_ADMIN) stafftype = "ADMIN" - msg = sanitize(copytext(msg, 1, MAX_MESSAGE_LEN)) + msg = sanitize(msg) log_admin("[key_name(src)] : [msg]") if (!msg) diff --git a/code/modules/admin/verbs/pray.dm b/code/modules/admin/verbs/pray.dm index 6e79bbbc3f..8b2d070003 100644 --- a/code/modules/admin/verbs/pray.dm +++ b/code/modules/admin/verbs/pray.dm @@ -6,7 +6,7 @@ usr << "\red Speech is currently admin-disabled." return - msg = sanitize(copytext(msg, 1, MAX_MESSAGE_LEN)) + msg = sanitize(msg) if(!msg) return if(usr.client) @@ -29,14 +29,14 @@ //log_admin("HELP: [key_name(src)]: [msg]") /proc/Centcomm_announce(var/text , var/mob/Sender , var/iamessage) - var/msg = sanitize(copytext(text, 1, MAX_MESSAGE_LEN)) + var/msg = sanitize(text) msg = "\blue CENTCOMM[iamessage ? " IA" : ""]:[key_name(Sender, 1)] (PP) (VV) (SM) (JMP) (CA) (BSA) (RPLY): [msg]" for(var/client/C in admins) if(R_ADMIN & C.holder.rights) C << msg /proc/Syndicate_announce(var/text , var/mob/Sender) - var/msg = sanitize(copytext(text, 1, MAX_MESSAGE_LEN)) + var/msg = sanitize(text) msg = "\blue ILLEGAL:[key_name(Sender, 1)] (PP) (VV) (SM) (JMP) (CA) (BSA) (RPLY): [msg]" for(var/client/C in admins) if(R_ADMIN & C.holder.rights) diff --git a/code/modules/admin/verbs/striketeam.dm b/code/modules/admin/verbs/striketeam.dm index c12d76b68d..c49e09d554 100644 --- a/code/modules/admin/verbs/striketeam.dm +++ b/code/modules/admin/verbs/striketeam.dm @@ -43,7 +43,7 @@ var/const/commandos_possible = 6 //if more Commandos are needed in the future choice = null while(!choice) - choice = sanitize(copytext(input(src, "Please specify which mission the strike team shall undertake.", "Specify Mission", ""),1,MAX_MESSAGE_LEN)) + choice = sanitize(input(src, "Please specify which mission the strike team shall undertake.", "Specify Mission", "")) if(!choice) if(alert("Error, no mission set. Do you want to exit the setup process?",,"Yes","No")=="Yes") return diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 6dd9cffe5b..942cb9c107 100755 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -1291,7 +1291,7 @@ datum/preferences if("metadata") var/new_metadata = input(user, "Enter any information you'd like others to see, such as Roleplay-preferences:", "Game Preference" , metadata) as message|null if(new_metadata) - metadata = sanitize(copytext(new_metadata,1,MAX_MESSAGE_LEN)) + metadata = sanitize(new_metadata) if("b_type") var/new_b_type = input(user, "Choose your character's blood-type:", "Character Preference") as null|anything in list( "A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-" ) @@ -1504,7 +1504,7 @@ datum/preferences if(choice == "Other") var/raw_choice = input(user, "Please enter a home system.") as text|null if(raw_choice) - home_system = sanitize(copytext(raw_choice,1,MAX_MESSAGE_LEN)) + home_system = sanitize(raw_choice) return home_system = choice if("citizenship") @@ -1514,7 +1514,7 @@ datum/preferences if(choice == "Other") var/raw_choice = input(user, "Please enter your current citizenship.", "Character Preference") as text|null if(raw_choice) - citizenship = sanitize(copytext(raw_choice,1,MAX_MESSAGE_LEN)) + citizenship = sanitize(raw_choice) return citizenship = choice if("faction") @@ -1524,7 +1524,7 @@ datum/preferences if(choice == "Other") var/raw_choice = input(user, "Please enter a faction.") as text|null if(raw_choice) - faction = sanitize(copytext(raw_choice,1,MAX_MESSAGE_LEN)) + faction = sanitize(raw_choice) return faction = choice if("religion") @@ -1534,7 +1534,7 @@ datum/preferences if(choice == "Other") var/raw_choice = input(user, "Please enter a religon.") as text|null if(raw_choice) - religion = sanitize(copytext(raw_choice,1,MAX_MESSAGE_LEN)) + religion = sanitize(raw_choice) return religion = choice else diff --git a/code/modules/clothing/masks/voice.dm b/code/modules/clothing/masks/voice.dm index c30e1ea48b..6899fef1ef 100644 --- a/code/modules/clothing/masks/voice.dm +++ b/code/modules/clothing/masks/voice.dm @@ -21,7 +21,7 @@ set category = "Object" set src in usr - var/voice = sanitize(copytext(name,1,MAX_MESSAGE_LEN)) + var/voice = sanitize(name, MAX_NAME_LEN) if(!voice || !length(voice)) return changer.voice = voice usr << "You are now mimicking [changer.voice]." diff --git a/code/modules/clothing/spacesuits/rig/modules/utility.dm b/code/modules/clothing/spacesuits/rig/modules/utility.dm index 6568c3ca5d..c670b93791 100644 --- a/code/modules/clothing/spacesuits/rig/modules/utility.dm +++ b/code/modules/clothing/spacesuits/rig/modules/utility.dm @@ -133,7 +133,7 @@ /obj/item/rig_module/chem_dispenser/ninja interface_desc = "Dispenses loaded chemicals directly into the wearer's bloodstream. This variant is made to be extremely light and flexible." - + //just over a syringe worth of each. Want more? Go refill. Gives the ninja another reason to have to show their face. charges = list( list("tricordrazine", "tricordrazine", 0, 20), @@ -283,7 +283,7 @@ var/raw_choice = input(usr, "Please enter a new name.") as text|null if(!raw_choice) return 0 - voice_holder.voice = sanitize(copytext(raw_choice,1,MAX_MESSAGE_LEN)) + voice_holder.voice = sanitize(raw_choice) usr << "You are now mimicking [voice_holder.voice]." return 1 diff --git a/code/modules/library/lib_items.dm b/code/modules/library/lib_items.dm index cd172b41ee..04906983e1 100644 --- a/code/modules/library/lib_items.dm +++ b/code/modules/library/lib_items.dm @@ -35,7 +35,7 @@ if(!newname) return else - name = ("bookcase ([sanitize(newname)])") + name = ("bookcase ([sanitizeSafe(newname)])") else ..() diff --git a/code/modules/library/lib_machines.dm b/code/modules/library/lib_machines.dm index 8544543531..5d390948a3 100644 --- a/code/modules/library/lib_machines.dm +++ b/code/modules/library/lib_machines.dm @@ -300,12 +300,12 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f if(checkoutperiod < 1) checkoutperiod = 1 if(href_list["editbook"]) - buffer_book = sanitize(copytext(input("Enter the book's title:") as text|null,1,MAX_MESSAGE_LEN)) + buffer_book = sanitizeSafe(input("Enter the book's title:") as text|null) if(href_list["editmob"]) - buffer_mob = sanitize(copytext(input("Enter the recipient's name:") as text|null,1,MAX_NAME_LEN)) + buffer_mob = sanitize(input("Enter the recipient's name:") as text|null, MAX_NAME_LEN) if(href_list["checkout"]) var/datum/borrowbook/b = new /datum/borrowbook - b.bookname = sanitize(buffer_book) + b.bookname = sanitizeSafe(buffer_book) b.mobname = sanitize(buffer_mob) b.getdate = world.time b.duedate = world.time + (checkoutperiod * 600) @@ -317,7 +317,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f var/obj/item/weapon/book/b = locate(href_list["delbook"]) inventory.Remove(b) if(href_list["setauthor"]) - var/newauthor = sanitize(copytext(input("Enter the author's name: ") as text|null,1,MAX_MESSAGE_LEN)) + var/newauthor = sanitize(input("Enter the author's name: ") as text|null) if(newauthor) scanner.cache.author = newauthor if(href_list["setcategory"]) diff --git a/code/modules/mob/emote.dm b/code/modules/mob/emote.dm index 8862479b2a..5645773ea0 100644 --- a/code/modules/mob/emote.dm +++ b/code/modules/mob/emote.dm @@ -12,7 +12,7 @@ var/input if(!message) - input = sanitize(copytext(input(src,"Choose an emote to display.") as text|null,1,MAX_MESSAGE_LEN)) + input = sanitize(input(src,"Choose an emote to display.") as text|null) else input = message if(input) @@ -108,7 +108,7 @@ var/input if(!message) - input = sanitize(copytext(input(src, "Choose an emote to display.") as text|null, 1, MAX_MESSAGE_LEN)) + input = sanitize(input(src, "Choose an emote to display.") as text|null) else input = message diff --git a/code/modules/mob/living/carbon/brain/say.dm b/code/modules/mob/living/carbon/brain/say.dm index e602916d8c..d5ac4f756d 100644 --- a/code/modules/mob/living/carbon/brain/say.dm +++ b/code/modules/mob/living/carbon/brain/say.dm @@ -32,5 +32,5 @@ if(istype(container, /obj/item/device/mmi/radio_enabled)) var/obj/item/device/mmi/radio_enabled/R = container if(R.radio) - spawn(0) R.radio.hear_talk(src, trim(sanitize(message)), verb, speaking) + spawn(0) R.radio.hear_talk(src, sanitize(message), verb, speaking) ..(trim(message), speaking, verb) diff --git a/code/modules/mob/living/carbon/human/emote.dm b/code/modules/mob/living/carbon/human/emote.dm index 2140fe22b3..258c8cbcd1 100644 --- a/code/modules/mob/living/carbon/human/emote.dm +++ b/code/modules/mob/living/carbon/human/emote.dm @@ -50,7 +50,7 @@ m_type = 1 if ("custom") - var/input = sanitize(copytext(input("Choose an emote to display.") as text|null,1,MAX_MESSAGE_LEN)) + var/input = sanitize(input("Choose an emote to display.") as text|null) if (!input) return var/input2 = input("Is this a visible or hearable emote?") in list("Visible","Hearable") @@ -577,7 +577,7 @@ set desc = "Sets a description which will be shown when someone examines you." set category = "IC" - pose = sanitize(copytext(input(usr, "This is [src]. \He is...", "Pose", null) as text, 1, MAX_MESSAGE_LEN)) + pose = sanitize(input(usr, "This is [src]. \He is...", "Pose", null) as text) /mob/living/carbon/human/verb/set_flavor() set name = "Set Flavour Text" diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index fd8be289e9..c3c2110872 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -501,7 +501,7 @@ for (var/datum/data/record/R in data_core.security) if (R.fields["id"] == E.fields["id"]) if(hasHUD(usr,"security")) - var/t1 = sanitize(copytext(input("Add Comment:", "Sec. records", null, null) as message,1,MAX_MESSAGE_LEN)) + var/t1 = sanitize(input("Add Comment:", "Sec. records", null, null) as message) if ( !(t1) || usr.stat || usr.restrained() || !(hasHUD(usr,"security")) ) return var/counter = 1 @@ -630,7 +630,7 @@ for (var/datum/data/record/R in data_core.medical) if (R.fields["id"] == E.fields["id"]) if(hasHUD(usr,"medical")) - var/t1 = sanitize(copytext(input("Add Comment:", "Med. records", null, null) as message,1,MAX_MESSAGE_LEN)) + var/t1 = sanitize(input("Add Comment:", "Med. records", null, null) as message) if ( !(t1) || usr.stat || usr.restrained() || !(hasHUD(usr,"medical")) ) return var/counter = 1 diff --git a/code/modules/mob/living/carbon/human/human_powers.dm b/code/modules/mob/living/carbon/human/human_powers.dm index 1150a52e71..10988afb92 100644 --- a/code/modules/mob/living/carbon/human/human_powers.dm +++ b/code/modules/mob/living/carbon/human/human_powers.dm @@ -175,7 +175,7 @@ text = input("What would you like to say?", "Speak to creature", null, null) - text = trim(sanitize(copytext(text, 1, MAX_MESSAGE_LEN))) + text = sanitize(text) if(!text) return @@ -213,7 +213,7 @@ set desc = "Whisper silently to someone over a distance." set category = "Abilities" - var/msg = sanitize(copytext(input("Message:", "Psychic Whisper") as text|null, 1, MAX_MESSAGE_LEN)) + var/msg = sanitize(input("Message:", "Psychic Whisper") as text|null) if(msg) log_say("PsychicWhisper: [key_name(src)]->[M.key] : [msg]") M << "\green You hear a strange, alien voice in your head... \italic [msg]" diff --git a/code/modules/mob/living/carbon/metroid/items.dm b/code/modules/mob/living/carbon/metroid/items.dm index bce1679472..9f10399112 100644 --- a/code/modules/mob/living/carbon/metroid/items.dm +++ b/code/modules/mob/living/carbon/metroid/items.dm @@ -146,7 +146,7 @@ pet.colour = "[M.colour]" user <<"You feed the slime the potion, removing it's powers and calming it." del(M) - var/newname = sanitize(copytext(input(user, "Would you like to give the slime a name?", "Name your new pet", "pet slime") as null|text,1,MAX_NAME_LEN)) + var/newname = sanitize(input(user, "Would you like to give the slime a name?", "Name your new pet", "pet slime") as null|text, MAX_NAME_LEN) if (!newname) newname = "pet slime" @@ -177,7 +177,7 @@ pet.colour = "[M.colour]" user <<"You feed the slime the potion, removing it's powers and calming it." del(M) - var/newname = sanitize(copytext(input(user, "Would you like to give the slime a name?", "Name your new pet", "pet slime") as null|text,1,MAX_NAME_LEN)) + var/newname = sanitize(input(user, "Would you like to give the slime a name?", "Name your new pet", "pet slime") as null|text, MAX_NAME_LEN) if (!newname) newname = "pet slime" diff --git a/code/modules/mob/living/silicon/pai/recruit.dm b/code/modules/mob/living/silicon/pai/recruit.dm index f7814b77f3..195d58fb34 100644 --- a/code/modules/mob/living/silicon/pai/recruit.dm +++ b/code/modules/mob/living/silicon/pai/recruit.dm @@ -57,32 +57,32 @@ var/datum/paiController/paiController // Global handler for pAI candidates if("name") t = input("Enter a name for your pAI", "pAI Name", candidate.name) as text if(t) - candidate.name = sanitize(copytext(t,1,MAX_NAME_LEN)) + candidate.name = sanitizeSafe(t, MAX_NAME_LEN) if("desc") t = input("Enter a description for your pAI", "pAI Description", candidate.description) as message if(t) - candidate.description = sanitize(copytext(t,1,MAX_MESSAGE_LEN)) + candidate.description = sanitize(t) if("role") t = input("Enter a role for your pAI", "pAI Role", candidate.role) as text if(t) - candidate.role = sanitize(copytext(t,1,MAX_MESSAGE_LEN)) + candidate.role = sanitize(t) if("ooc") t = input("Enter any OOC comments", "pAI OOC Comments", candidate.comments) as message if(t) - candidate.comments = sanitize(copytext(t,1,MAX_MESSAGE_LEN)) + candidate.comments = sanitize(t) if("save") candidate.savefile_save(usr) if("load") candidate.savefile_load(usr) //In case people have saved unsanitized stuff. if(candidate.name) - candidate.name = sanitize(copytext(candidate.name,1,MAX_NAME_LEN)) + candidate.name = sanitizeSafe(candidate.name, MAX_NAME_LEN) if(candidate.description) - candidate.description = sanitize(copytext(candidate.description,1,MAX_MESSAGE_LEN)) + candidate.description = sanitize(candidate.description) if(candidate.role) - candidate.role = sanitize(copytext(candidate.role,1,MAX_MESSAGE_LEN)) + candidate.role = sanitize(candidate.role) if(candidate.comments) - candidate.comments = sanitize(copytext(candidate.comments,1,MAX_MESSAGE_LEN)) + candidate.comments = sanitize(candidate.comments) if("submit") if(candidate) diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index acce80ea36..62daf30a70 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -235,14 +235,14 @@ set desc = "Sets a description which will be shown when someone examines you." set category = "IC" - pose = sanitize(copytext(input(usr, "This is [src]. It is...", "Pose", null) as text, 1, MAX_MESSAGE_LEN)) + pose = sanitize(input(usr, "This is [src]. It is...", "Pose", null) as text) /mob/living/silicon/verb/set_flavor() set name = "Set Flavour Text" set desc = "Sets an extended description of your character's features." set category = "IC" - flavor_text = sanitize(copytext(input(usr, "Please enter your new flavour text.", "Flavour text", null) as text, 1)) + flavor_text = sanitize(input(usr, "Please enter your new flavour text.", "Flavour text", null) as text) /mob/living/silicon/binarycheck() return 1 diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 0cbab16581..2fff16a617 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -257,7 +257,7 @@ var/list/global/organ_rel_size = list( for(var/obj/item/weapon/grab/G in target.grabbed_by) if(G.state >= GRAB_AGGRESSIVE) return zone - + var/miss_chance = 10 if (zone in base_miss_chance) miss_chance = base_miss_chance[zone] @@ -340,7 +340,7 @@ proc/slur(phrase) n_letter = text("[n_letter]-[n_letter]") t = text("[t][n_letter]")//since the above is ran through for each letter, the text just adds up back to the original word. p++//for each letter p is increased to find where the next letter will be. - return sanitize(copytext(t,1,MAX_MESSAGE_LEN)) + return sanitize(t) proc/Gibberish(t, p)//t is the inputted message, and any value higher than 70 for p will cause letters to be replaced instead of added @@ -387,7 +387,7 @@ It's fairly easy to fix if dealing with single letters but not so much with comp n_letter = text("[n_letter]") t = text("[t][n_letter]") p=p+n_mod - return sanitize(copytext(t,1,MAX_MESSAGE_LEN)) + return sanitize(t) /proc/shake_camera(mob/M, duration, strength=1) diff --git a/code/modules/paperwork/folders.dm b/code/modules/paperwork/folders.dm index c004844c50..ddc211cc7c 100644 --- a/code/modules/paperwork/folders.dm +++ b/code/modules/paperwork/folders.dm @@ -35,7 +35,7 @@ user << "You put the [W] into \the [src]." update_icon() else if(istype(W, /obj/item/weapon/pen)) - var/n_name = sanitize(copytext(input(usr, "What would you like to label the folder?", "Folder Labelling", null) as text, 1, MAX_NAME_LEN)) + var/n_name = sanitizeSafe(input(usr, "What would you like to label the folder?", "Folder Labelling", null) as text, MAX_NAME_LEN) if((loc == usr && usr.stat == 0)) name = "folder[(n_name ? text("- '[n_name]'") : null)]" return diff --git a/code/modules/paperwork/paper.dm b/code/modules/paperwork/paper.dm index 73d7005eb9..ebaf6b20ca 100644 --- a/code/modules/paperwork/paper.dm +++ b/code/modules/paperwork/paper.dm @@ -86,7 +86,7 @@ if((CLUMSY in usr.mutations) && prob(50)) usr << "You cut yourself on the paper." return - var/n_name = sanitize(copytext(input(usr, "What would you like to label the paper?", "Paper Labelling", null) as text, 1, MAX_NAME_LEN)) + var/n_name = sanitizeSafe(input(usr, "What would you like to label the paper?", "Paper Labelling", null) as text, MAX_NAME_LEN) if((loc == usr && usr.stat == 0)) name = "[(n_name ? text("[n_name]") : initial(name))]" if(name != "paper") diff --git a/code/modules/paperwork/paper_bundle.dm b/code/modules/paperwork/paper_bundle.dm index 39ad7323ed..dfa5103ec2 100644 --- a/code/modules/paperwork/paper_bundle.dm +++ b/code/modules/paperwork/paper_bundle.dm @@ -192,7 +192,7 @@ set category = "Object" set src in usr - var/n_name = sanitize(copytext(input(usr, "What would you like to label the bundle?", "Bundle Labelling", null) as text, 1, MAX_NAME_LEN)) + var/n_name = sanitizeSafe(input(usr, "What would you like to label the bundle?", "Bundle Labelling", null) as text, MAX_NAME_LEN) if((loc == usr && usr.stat == 0)) name = "[(n_name ? text("[n_name]") : "paper")]" add_fingerprint(usr) diff --git a/code/modules/paperwork/photography.dm b/code/modules/paperwork/photography.dm index 1b6756334c..24a321ac87 100644 --- a/code/modules/paperwork/photography.dm +++ b/code/modules/paperwork/photography.dm @@ -43,7 +43,7 @@ var/global/photo_count = 0 /obj/item/weapon/photo/attackby(obj/item/weapon/P as obj, mob/user as mob) if(istype(P, /obj/item/weapon/pen) || istype(P, /obj/item/toy/crayon)) - var/txt = sanitize(copytext(input(user, "What would you like to write on the back?", "Photo Writing", null) as text, 1, 128)) + var/txt = sanitize(input(user, "What would you like to write on the back?", "Photo Writing", null) as text, 128) if(loc == user && user.stat == 0) scribble = txt ..() @@ -70,7 +70,7 @@ var/global/photo_count = 0 set category = "Object" set src in usr - var/n_name = sanitize(copytext(input(usr, "What would you like to label the photo?", "Photo Labelling", null) as text, 1, MAX_NAME_LEN)) + var/n_name = sanitizeSafe(input(usr, "What would you like to label the photo?", "Photo Labelling", null) as text, MAX_NAME_LEN) //loc.loc check is for making possible renaming photos in clipboards if(( (loc == usr || (loc.loc && loc.loc == usr)) && usr.stat == 0)) name = "[(n_name ? text("[n_name]") : "photo")]" diff --git a/code/modules/projectiles/ammunition.dm b/code/modules/projectiles/ammunition.dm index d31ba64814..01f6a55044 100644 --- a/code/modules/projectiles/ammunition.dm +++ b/code/modules/projectiles/ammunition.dm @@ -31,9 +31,9 @@ if(!BB) user << "\blue There is no bullet in the casing to inscribe anything into." return - + var/tmp_label = "" - var/label_text = sanitize(copytext(input(user, "Inscribe some text into \the [initial(BB.name)]","Inscription",tmp_label), 1, MAX_NAME_LEN)) + var/label_text = sanitizeSafe(input(user, "Inscribe some text into \the [initial(BB.name)]","Inscription",tmp_label), MAX_NAME_LEN) if(length(label_text) > 20) user << "\red The inscription can be at most 20 characters long." else if(!label_text) @@ -54,7 +54,7 @@ //Gun loading types #define SINGLE_CASING 1 //The gun only accepts ammo_casings. ammo_magazines should never have this as their mag_type. -#define SPEEDLOADER 2 //Transfers casings from the mag to the gun when used. +#define SPEEDLOADER 2 //Transfers casings from the mag to the gun when used. #define MAGAZINE 4 //The magazine item itself goes inside the gun //An item that holds casings and can be used to put them inside guns @@ -71,15 +71,15 @@ w_class = 2 throw_speed = 4 throw_range = 10 - + var/list/stored_ammo = list() var/mag_type = SPEEDLOADER //ammo_magazines can only be used with compatible guns. This is not a bitflag, the load_method var on guns is. var/caliber = "357" var/max_ammo = 7 - + var/ammo_type = /obj/item/ammo_casing //ammo type that is initially loaded var/initial_ammo = null - + var/multiple_sprites = 0 //because BYOND doesn't support numbers as keys in associative lists var/list/icon_keys = list() //keys @@ -145,10 +145,10 @@ var/typestr = "[M.type]" if(!(typestr in magazine_icondata_keys) || !(typestr in magazine_icondata_states)) magazine_icondata_cache_add(M) - + M.icon_keys = magazine_icondata_keys[typestr] M.ammo_states = magazine_icondata_states[typestr] - + /proc/magazine_icondata_cache_add(var/obj/item/ammo_magazine/M) var/list/icon_keys = list() var/list/ammo_states = list() diff --git a/code/modules/reagents/Chemistry-Machinery.dm b/code/modules/reagents/Chemistry-Machinery.dm index 6885f82d5d..2fab30fe45 100644 --- a/code/modules/reagents/Chemistry-Machinery.dm +++ b/code/modules/reagents/Chemistry-Machinery.dm @@ -406,7 +406,7 @@ if(type in diseases) // Make sure this is a disease D = new type(0, null) var/list/data = list("viruses"=list(D)) - var/name = sanitize(input(usr,"Name:","Name the culture",D.name)) + var/name = sanitizeSafe(input(usr,"Name:","Name the culture",D.name)) if(!name || name == " ") name = D.name B.name = "[name] culture bottle" B.desc = "A small bottle. Contains [D.agent] culture in synthblood medium." diff --git a/code/modules/reagents/reagent_containers/glass.dm b/code/modules/reagents/reagent_containers/glass.dm index c056d4479c..12b56021d4 100644 --- a/code/modules/reagents/reagent_containers/glass.dm +++ b/code/modules/reagents/reagent_containers/glass.dm @@ -138,7 +138,7 @@ attackby(obj/item/weapon/W as obj, mob/user as mob) if(istype(W, /obj/item/weapon/pen) || istype(W, /obj/item/device/flashlight/pen)) - var/tmp_label = sanitize(copytext(input(user, "Enter a label for [src.name]","Label",src.label_text), 1, MAX_NAME_LEN)) + var/tmp_label = sanitizeSafe(input(user, "Enter a label for [src.name]","Label",src.label_text), MAX_NAME_LEN) if(length(tmp_label) > 10) user << "\red The label can be at most 10 characters long." else diff --git a/code/modules/recycling/sortingmachinery.dm b/code/modules/recycling/sortingmachinery.dm index 5b375ed8f7..7a7622dd77 100755 --- a/code/modules/recycling/sortingmachinery.dm +++ b/code/modules/recycling/sortingmachinery.dm @@ -43,7 +43,7 @@ else if(istype(W, /obj/item/weapon/pen)) switch(alert("What would you like to alter?",,"Title","Description", "Cancel")) if("Title") - var/str = trim(sanitize(copytext(input(usr,"Label text?","Set label",""),1,MAX_NAME_LEN))) + var/str = sanitizeSafe(input(usr,"Label text?","Set label",""), MAX_NAME_LEN) if(!str || !length(str)) usr << " Invalid text." return @@ -57,7 +57,7 @@ else nameset = 1 if("Description") - var/str = trim(sanitize(copytext(input(usr,"Label text?","Set label",""),1,MAX_MESSAGE_LEN))) + var/str = sanitize(input(usr,"Label text?","Set label","")) if(!str || !length(str)) usr << "\red Invalid text." return @@ -150,7 +150,7 @@ else if(istype(W, /obj/item/weapon/pen)) switch(alert("What would you like to alter?",,"Title","Description", "Cancel")) if("Title") - var/str = trim(sanitize(copytext(input(usr,"Label text?","Set label",""),1,MAX_NAME_LEN))) + var/str = sanitizeSafe(input(usr,"Label text?","Set label",""), MAX_NAME_LEN) if(!str || !length(str)) usr << " Invalid text." return @@ -165,7 +165,7 @@ nameset = 1 if("Description") - var/str = trim(sanitize(copytext(input(usr,"Label text?","Set label",""),1,MAX_MESSAGE_LEN))) + var/str = sanitize(input(usr,"Label text?","Set label","")) if(!str || !length(str)) usr << "\red Invalid text." return From f8822626bbc1a078c2075ef34a38e92d52e31c48 Mon Sep 17 00:00:00 2001 From: volas Date: Mon, 23 Mar 2015 01:38:09 +0300 Subject: [PATCH 3/5] sanitize() refactor: second pass(other sanitize functions) --- code/__HELPERS/unsorted.dm | 2 +- code/defines/procs/announce.dm | 4 ++-- .../gamemodes/changeling/changeling_powers.dm | 2 +- code/game/gamemodes/cult/runes.dm | 2 +- code/game/machinery/bots/cleanbot.dm | 2 +- code/game/machinery/bots/ed209bot.dm | 2 +- code/game/machinery/bots/floorbot.dm | 4 ++-- code/game/machinery/bots/medbot.dm | 2 +- code/game/machinery/bots/secbot.dm | 2 +- code/game/machinery/camera/camera_assembly.dm | 4 ++-- code/game/machinery/computer/card.dm | 2 +- .../game/machinery/computer/communications.dm | 4 ++-- code/game/machinery/computer/guestpass.dm | 4 ++-- code/game/machinery/computer/security.dm | 2 +- code/game/machinery/computer/skills.dm | 2 +- .../computer3/computers/communications.dm | 4 ++-- .../machinery/computer3/computers/security.dm | 2 +- code/game/machinery/newscaster.dm | 18 +++++------------ code/game/mecha/mecha.dm | 6 +++--- code/game/mecha/mecha_control_console.dm | 4 ++-- code/game/objects/items/blueprints.dm | 4 ++-- code/game/objects/items/devices/PDA/PDA.dm | 5 +++-- code/game/objects/items/robot/robot_parts.dm | 2 +- .../objects/items/robot/robot_upgrades.dm | 2 +- code/game/objects/items/weapons/AI_modules.dm | 8 ++++---- code/game/objects/items/weapons/cards_ids.dm | 2 +- .../circuitboards/computer/camera_monitor.dm | 2 +- .../objects/items/weapons/implants/implant.dm | 4 ++-- code/game/objects/structures/door_assembly.dm | 2 +- code/modules/admin/admin.dm | 2 +- code/modules/admin/admin_verbs.dm | 2 +- code/modules/admin/topic.dm | 20 ++++++------------- code/modules/client/preferences.dm | 2 +- code/modules/client/preferences_savefile.dm | 2 +- .../modules/detectivework/scanning_console.dm | 4 ++-- code/modules/library/lib_items.dm | 10 +++++----- code/modules/mob/dead/observer/observer.dm | 2 +- code/modules/mob/dead/observer/say.dm | 4 ++-- code/modules/mob/living/carbon/alien/say.dm | 2 +- code/modules/mob/living/carbon/human/human.dm | 2 +- code/modules/mob/living/carbon/human/say.dm | 2 +- .../mob/living/carbon/human/whisper.dm | 2 +- code/modules/mob/living/silicon/say.dm | 2 +- .../simple_animal/borer/borer_captive.dm | 2 +- .../mob/living/simple_animal/borer/say.dm | 2 +- code/modules/mob/say.dm | 2 +- code/modules/nano/modules/law_manager.dm | 10 +++++----- code/modules/paperwork/pen.dm | 2 +- .../projectiles/guns/projectile/pistol.dm | 2 +- .../projectiles/guns/projectile/revolver.dm | 2 +- code/modules/reagents/Chemistry-Machinery.dm | 2 +- 51 files changed, 86 insertions(+), 101 deletions(-) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index c00bb17b1d..918fee1389 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -311,7 +311,7 @@ Turf and target are seperate in case you want to teleport some distance from a t newname = input(src,"You are a [role]. Would you like to change your name to something else?", "Name change",oldname) as text if((world.time-time_passed)>300) return //took too long - newname = reject_bad_name(newname,allow_numbers) //returns null if the name doesn't meet some basic requirements. Tidies up a few other things like bad-characters. + newname = sanitizeName(newname, ,allow_numbers) //returns null if the name doesn't meet some basic requirements. Tidies up a few other things like bad-characters. for(var/mob/living/M in player_list) if(M == src) diff --git a/code/defines/procs/announce.dm b/code/defines/procs/announce.dm index d3aef96c45..3e5454d8ac 100644 --- a/code/defines/procs/announce.dm +++ b/code/defines/procs/announce.dm @@ -36,8 +36,8 @@ var/tmp/message_title = new_title ? new_title : title var/tmp/message_sound = new_sound ? sound(new_sound) : sound - message = trim_strip_html_properly(message) - message_title = html_encode(message_title) + message = sanitize(message, extra = 0) + message_title = sanitizeSafe(message_title) Message(message, message_title) if(do_newscast) diff --git a/code/game/gamemodes/changeling/changeling_powers.dm b/code/game/gamemodes/changeling/changeling_powers.dm index 066604834e..703ce04828 100644 --- a/code/game/gamemodes/changeling/changeling_powers.dm +++ b/code/game/gamemodes/changeling/changeling_powers.dm @@ -697,7 +697,7 @@ var/list/datum/dna/hivemind_bank = list() src << "We return our vocal glands to their original location." return - var/mimic_voice = stripped_input(usr, "Enter a name to mimic.", "Mimic Voice", null, MAX_NAME_LEN) + var/mimic_voice = sanitize(input(usr, "Enter a name to mimic.", "Mimic Voice", null), MAX_NAME_LEN) if(!mimic_voice) return diff --git a/code/game/gamemodes/cult/runes.dm b/code/game/gamemodes/cult/runes.dm index b4b5ae4d51..511f86f7d5 100644 --- a/code/game/gamemodes/cult/runes.dm +++ b/code/game/gamemodes/cult/runes.dm @@ -564,7 +564,7 @@ var/list/sacrificed = list() // returns 0 if the rune is not used. returns 1 if the rune is used. communicate() . = 1 // Default output is 1. If the rune is deleted it will return 1 - var/input = stripped_input(usr, "Please choose a message to tell to the other acolytes.", "Voice of Blood", "") + var/input = sanitize(input(usr, "Please choose a message to tell to the other acolytes.", "Voice of Blood", "")) if(!input) if (istype(src)) fizzle() diff --git a/code/game/machinery/bots/cleanbot.dm b/code/game/machinery/bots/cleanbot.dm index f4d9dd0c59..4dcb838152 100644 --- a/code/game/machinery/bots/cleanbot.dm +++ b/code/game/machinery/bots/cleanbot.dm @@ -355,7 +355,7 @@ text("[src.oddbutton ? "Yes" : "No" del(src) else if (istype(W, /obj/item/weapon/pen)) - var/t = copytext(stripped_input(user, "Enter new robot name", src.name, src.created_name),1,MAX_NAME_LEN) + var/t = sanitizeSafe(input(user, "Enter new robot name", src.name, src.created_name), MAX_NAME_LEN) if (!t) return if (!in_range(src, usr) && src.loc != usr) diff --git a/code/game/machinery/bots/ed209bot.dm b/code/game/machinery/bots/ed209bot.dm index 639da55bf5..f225b9ce8d 100644 --- a/code/game/machinery/bots/ed209bot.dm +++ b/code/game/machinery/bots/ed209bot.dm @@ -58,7 +58,7 @@ ..() if(istype(W, /obj/item/weapon/pen)) - var/t = copytext(stripped_input(user, "Enter new robot name", src.name, src.created_name),1,MAX_NAME_LEN) + var/t = sanitizeSafe(input(user, "Enter new robot name", src.name, src.created_name), MAX_NAME_LEN) if(!t) return if(!in_range(src, usr) && src.loc != usr) return created_name = t diff --git a/code/game/machinery/bots/floorbot.dm b/code/game/machinery/bots/floorbot.dm index 54c8390234..b3c1c0376f 100644 --- a/code/game/machinery/bots/floorbot.dm +++ b/code/game/machinery/bots/floorbot.dm @@ -420,7 +420,7 @@ del(src) else if (istype(W, /obj/item/weapon/pen)) - var/t = copytext(stripped_input(user, "Enter new robot name", src.name, src.created_name),1,MAX_NAME_LEN) + var/t = sanitizeSafe(input(user, "Enter new robot name", src.name, src.created_name), MAX_NAME_LEN) if (!t) return if (!in_range(src, usr) && src.loc != usr) @@ -439,7 +439,7 @@ user.drop_from_inventory(src) del(src) else if (istype(W, /obj/item/weapon/pen)) - var/t = stripped_input(user, "Enter new robot name", src.name, src.created_name) + var/t = sanitizeSafe(input(user, "Enter new robot name", src.name, src.created_name), MAX_NAME_LEN) if (!t) return diff --git a/code/game/machinery/bots/medbot.dm b/code/game/machinery/bots/medbot.dm index fbcb7d448e..8ce3522707 100644 --- a/code/game/machinery/bots/medbot.dm +++ b/code/game/machinery/bots/medbot.dm @@ -564,7 +564,7 @@ /obj/item/weapon/firstaid_arm_assembly/attackby(obj/item/weapon/W as obj, mob/user as mob) ..() if(istype(W, /obj/item/weapon/pen)) - var/t = copytext(stripped_input(user, "Enter new robot name", src.name, src.created_name),1,MAX_NAME_LEN) + var/t = sanitizeSafe(input(user, "Enter new robot name", src.name, src.created_name), MAX_NAME_LEN) if (!t) return if (!in_range(src, usr) && src.loc != usr) diff --git a/code/game/machinery/bots/secbot.dm b/code/game/machinery/bots/secbot.dm index f1283e5efc..92b7297c42 100644 --- a/code/game/machinery/bots/secbot.dm +++ b/code/game/machinery/bots/secbot.dm @@ -838,7 +838,7 @@ Auto Patrol: []"}, del(src) else if(istype(W, /obj/item/weapon/pen)) - var/t = copytext(stripped_input(user, "Enter new robot name", src.name, src.created_name),1,MAX_NAME_LEN) + var/t = sanitizeSafe(input(user, "Enter new robot name", src.name, src.created_name), MAX_NAME_LEN) if(!t) return if(!in_range(src, usr) && src.loc != usr) diff --git a/code/game/machinery/camera/camera_assembly.dm b/code/game/machinery/camera/camera_assembly.dm index 4ece6594f0..a038ece414 100644 --- a/code/game/machinery/camera/camera_assembly.dm +++ b/code/game/machinery/camera/camera_assembly.dm @@ -78,7 +78,7 @@ if(isscrewdriver(W)) playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) - var/input = strip_html(input(usr, "Which networks would you like to connect this camera to? Separate networks with a comma. No Spaces!\nFor example: SS13,Security,Secret ", "Set Network", "SS13")) + var/input = sanitize(input(usr, "Which networks would you like to connect this camera to? Separate networks with a comma. No Spaces!\nFor example: SS13,Security,Secret ", "Set Network", "SS13")) if(!input) usr << "No input found please hang up and try your call again." return @@ -90,7 +90,7 @@ var/area/camera_area = get_area(src) var/temptag = "[sanitize(camera_area.name)] ([rand(1, 999)])" - input = strip_html(input(usr, "How would you like to name the camera?", "Set Camera Name", temptag)) + input = sanitizeSafe(input(usr, "How would you like to name the camera?", "Set Camera Name", temptag)) state = 4 var/obj/machinery/camera/C = new(src.loc) diff --git a/code/game/machinery/computer/card.dm b/code/game/machinery/computer/card.dm index 53a65f65e4..4e97506088 100644 --- a/code/game/machinery/computer/card.dm +++ b/code/game/machinery/computer/card.dm @@ -222,7 +222,7 @@ if (is_authenticated()) var/t2 = modify if ((modify == t2 && (in_range(src, usr) || (istype(usr, /mob/living/silicon))) && istype(loc, /turf))) - var/temp_name = reject_bad_name(href_list["reg"]) + var/temp_name = sanitizeName(href_list["reg"]) if(temp_name) modify.registered_name = temp_name else diff --git a/code/game/machinery/computer/communications.dm b/code/game/machinery/computer/communications.dm index c3e12d4a58..4015b907f9 100644 --- a/code/game/machinery/computer/communications.dm +++ b/code/game/machinery/computer/communications.dm @@ -187,7 +187,7 @@ if(centcomm_message_cooldown) usr << "\red Arrays recycling. Please stand by." return - var/input = stripped_input(usr, "Please choose a message to transmit to Centcomm via quantum entanglement. Please be aware that this process is very expensive, and abuse will lead to... termination. Transmission does not guarantee a response. There is a 30 second delay before you may send another message, be clear, full and concise.", "To abort, send an empty message.", "") + var/input = sanitize(input("Please choose a message to transmit to Centcomm via quantum entanglement. Please be aware that this process is very expensive, and abuse will lead to... termination. Transmission does not guarantee a response. There is a 30 second delay before you may send another message, be clear, full and concise.", "To abort, send an empty message.", "")) if(!input || !(usr in view(1,src))) return Centcomm_announce(input, usr) @@ -204,7 +204,7 @@ if(centcomm_message_cooldown) usr << "\red Arrays recycling. Please stand by." return - var/input = stripped_input(usr, "Please choose a message to transmit to \[ABNORMAL ROUTING CORDINATES\] via quantum entanglement. Please be aware that this process is very expensive, and abuse will lead to... termination. Transmission does not guarantee a response. There is a 30 second delay before you may send another message, be clear, full and concise.", "To abort, send an empty message.", "") + var/input = sanitize(input(usr, "Please choose a message to transmit to \[ABNORMAL ROUTING CORDINATES\] via quantum entanglement. Please be aware that this process is very expensive, and abuse will lead to... termination. Transmission does not guarantee a response. There is a 30 second delay before you may send another message, be clear, full and concise.", "To abort, send an empty message.", "")) if(!input || !(usr in view(1,src))) return Syndicate_announce(input, usr) diff --git a/code/game/machinery/computer/guestpass.dm b/code/game/machinery/computer/guestpass.dm index 121942a418..40fc0b9914 100644 --- a/code/game/machinery/computer/guestpass.dm +++ b/code/game/machinery/computer/guestpass.dm @@ -114,11 +114,11 @@ if (href_list["choice"]) switch(href_list["choice"]) if ("giv_name") - var/nam = strip_html_simple(input("Person pass is issued to", "Name", giv_name) as text|null) + var/nam = sanitize(input("Person pass is issued to", "Name", giv_name) as text|null) if (nam) giv_name = nam if ("reason") - var/reas = strip_html_simple(input("Reason why pass is issued", "Reason", reason) as text|null) + var/reas = sanitize(input("Reason why pass is issued", "Reason", reason) as text|null) if(reas) reason = reas if ("duration") diff --git a/code/game/machinery/computer/security.dm b/code/game/machinery/computer/security.dm index 1e4979b657..c05f0f78be 100644 --- a/code/game/machinery/computer/security.dm +++ b/code/game/machinery/computer/security.dm @@ -426,7 +426,7 @@ What a mess.*/ switch(href_list["field"]) if("name") if (istype(active1, /datum/data/record)) - var/t1 = reject_bad_name(input("Please input name:", "Secure. records", active1.fields["name"], null) as text) + var/t1 = sanitizeName(input("Please input name:", "Secure. records", active1.fields["name"], null) as text) if (!t1 || active1 != a1) return active1.fields["name"] = t1 diff --git a/code/game/machinery/computer/skills.dm b/code/game/machinery/computer/skills.dm index 0c93c15bfc..aa92a59094 100644 --- a/code/game/machinery/computer/skills.dm +++ b/code/game/machinery/computer/skills.dm @@ -309,7 +309,7 @@ What a mess.*/ switch(href_list["field"]) if("name") if (istype(active1, /datum/data/record)) - var/t1 = reject_bad_name(input("Please input name:", "Secure. records", active1.fields["name"], null) as text) + var/t1 = sanitizeName(input("Please input name:", "Secure. records", active1.fields["name"], null) as text) if ((!( t1 ) || !length(trim(t1)) || !( authenticated ) || usr.stat || usr.restrained() || (!in_range(src, usr) && (!istype(usr, /mob/living/silicon)))) || active1 != a1) return active1.fields["name"] = t1 diff --git a/code/game/machinery/computer3/computers/communications.dm b/code/game/machinery/computer3/computers/communications.dm index c8548bb933..f00b595c6c 100644 --- a/code/game/machinery/computer3/computers/communications.dm +++ b/code/game/machinery/computer3/computers/communications.dm @@ -192,7 +192,7 @@ if(centcomm_message_cooldown) usr << "Arrays recycling. Please stand by." return - var/input = stripped_input(usr, "Please choose a message to transmit to Centcomm via quantum entanglement. Please be aware that this process is very expensive, and abuse will lead to... termination. Transmission does not guarantee a response.", "To abort, send an empty message.", "") + var/input = sanitize(input("Please choose a message to transmit to Centcomm via quantum entanglement. Please be aware that this process is very expensive, and abuse will lead to... termination. Transmission does not guarantee a response.", "To abort, send an empty message.", "")) if(!input || !interactable()) return Centcomm_announce(input, usr) @@ -209,7 +209,7 @@ if(centcomm_message_cooldown) usr << "Arrays recycling. Please stand by." return - var/input = stripped_input(usr, "Please choose a message to transmit to \[ABNORMAL ROUTING CORDINATES\] via quantum entanglement. Please be aware that this process is very expensive, and abuse will lead to... termination. Transmission does not guarantee a response.", "To abort, send an empty message.", "") + var/input = sanitize(input(usr, "Please choose a message to transmit to \[ABNORMAL ROUTING CORDINATES\] via quantum entanglement. Please be aware that this process is very expensive, and abuse will lead to... termination. Transmission does not guarantee a response.", "To abort, send an empty message.", "")) if(!input || !interactable()) return Syndicate_announce(input, usr) diff --git a/code/game/machinery/computer3/computers/security.dm b/code/game/machinery/computer3/computers/security.dm index 4c2f7369d2..e00aab556d 100644 --- a/code/game/machinery/computer3/computers/security.dm +++ b/code/game/machinery/computer3/computers/security.dm @@ -444,7 +444,7 @@ What a mess.*/ switch(href_list["field"]) if("name") if (istype(active1, /datum/data/record)) - var/t1 = reject_bad_name(input("Please input name:", "Secure. records", active1.fields["name"], null) as text) + var/t1 = sanitizeName(input("Please input name:", "Secure. records", active1.fields["name"], null) as text) if ((!( t1 ) || !length(trim(t1)) || !( authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon)))) || active1 != a1) return active1.fields["name"] = t1 diff --git a/code/game/machinery/newscaster.dm b/code/game/machinery/newscaster.dm index 9f65c8235d..3a238e24b0 100644 --- a/code/game/machinery/newscaster.dm +++ b/code/game/machinery/newscaster.dm @@ -496,9 +496,7 @@ var/list/obj/machinery/newscaster/allCasters = list() //Global list that will co if ((usr.contents.Find(src) || ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon))) usr.set_machine(src) if(href_list["set_channel_name"]) - src.channel_name = strip_html(input(usr, "Provide a Feed Channel Name", "Network Channel Handler", "")) - while (findtext(src.channel_name," ") == 1) - src.channel_name = copytext(src.channel_name,2,lentext(src.channel_name)+1) + src.channel_name = sanitizeSafe(input(usr, "Provide a Feed Channel Name", "Network Channel Handler", "")) src.updateUsrDialog() //src.update_icon() @@ -541,9 +539,7 @@ var/list/obj/machinery/newscaster/allCasters = list() //Global list that will co src.updateUsrDialog() else if(href_list["set_new_message"]) - src.msg = strip_html(input(usr, "Write your Feed story", "Network Channel Handler", "")) - while (findtext(src.msg," ") == 1) - src.msg = copytext(src.msg,2,lentext(src.msg)+1) + src.msg = sanitize(input(usr, "Write your Feed story", "Network Channel Handler", "")) src.updateUsrDialog() else if(href_list["set_attachment"]) @@ -600,15 +596,11 @@ var/list/obj/machinery/newscaster/allCasters = list() //Global list that will co src.updateUsrDialog() else if(href_list["set_wanted_name"]) - src.channel_name = strip_html(input(usr, "Provide the name of the Wanted person", "Network Security Handler", "")) - while (findtext(src.channel_name," ") == 1) - src.channel_name = copytext(src.channel_name,2,lentext(src.channel_name)+1) + src.channel_name = sanitizeSafe(input(usr, "Provide the name of the Wanted person", "Network Security Handler", "")) src.updateUsrDialog() else if(href_list["set_wanted_desc"]) - src.msg = strip_html(input(usr, "Provide the a description of the Wanted person and any other details you deem important", "Network Security Handler", "")) - while (findtext(src.msg," ") == 1) - src.msg = copytext(src.msg,2,lentext(src.msg)+1) + src.msg = sanitize(input(usr, "Provide the a description of the Wanted person and any other details you deem important", "Network Security Handler", "")) src.updateUsrDialog() else if(href_list["submit_wanted"]) @@ -944,7 +936,7 @@ obj/item/weapon/newspaper/attackby(obj/item/weapon/W as obj, mob/user as mob) if(src.scribble_page == src.curr_page) user << "There's already a scribble in this page... You wouldn't want to make things too cluttered, would you?" else - var/s = strip_html( input(user, "Write something", "Newspaper", "") ) + var/s = sanitize(input(user, "Write something", "Newspaper", "")) s = sanitize(s) if (!s) return diff --git a/code/game/mecha/mecha.dm b/code/game/mecha/mecha.dm index b2bdadfdbe..c8d1014c9b 100644 --- a/code/game/mecha/mecha.dm +++ b/code/game/mecha/mecha.dm @@ -284,7 +284,7 @@ src.log_message("Interfaced with [src_object].") return STATUS_INTERACTIVE if(src_object in view(2, src)) - return STATUS_UPDATE //if they're close enough, allow the occupant to see the screen through the viewport or whatever. + return STATUS_UPDATE //if they're close enough, allow the occupant to see the screen through the viewport or whatever. /obj/mecha/proc/melee_action(atom/target) return @@ -1569,8 +1569,8 @@ return if (href_list["change_name"]) if(usr != src.occupant) return - var/newname = strip_html_simple(input(occupant,"Choose new exosuit name","Rename exosuit",initial(name)) as text, MAX_NAME_LEN) - if(newname && trim(newname)) + var/newname = sanitizeSafe(input(occupant,"Choose new exosuit name","Rename exosuit",initial(name)) as text, MAX_NAME_LEN) + if(newname) name = newname else alert(occupant, "nope.avi") diff --git a/code/game/mecha/mecha_control_console.dm b/code/game/mecha/mecha_control_console.dm index 051f2e8129..8fa25a3568 100644 --- a/code/game/mecha/mecha_control_console.dm +++ b/code/game/mecha/mecha_control_console.dm @@ -43,9 +43,9 @@ var/datum/topic_input/filter = new /datum/topic_input(href,href_list) if(href_list["send_message"]) var/obj/item/mecha_parts/mecha_tracking/MT = filter.getObj("send_message") - var/message = strip_html_simple(input(usr,"Input message","Transmit message") as text) + var/message = sanitize(input(usr,"Input message","Transmit message") as text) var/obj/mecha/M = MT.in_mecha() - if(trim(message) && M) + if(message && M) M.occupant_message(message) return if(href_list["shock"]) diff --git a/code/game/objects/items/blueprints.dm b/code/game/objects/items/blueprints.dm index f0d8a820c0..facafe41f2 100644 --- a/code/game/objects/items/blueprints.dm +++ b/code/game/objects/items/blueprints.dm @@ -114,7 +114,7 @@ move an amendment to the drawing.

    usr << "\red Error! Please notify administration!" return var/list/turf/turfs = res - var/str = trim(stripped_input(usr,"New area name:","Blueprint Editing", "", MAX_NAME_LEN)) + var/str = sanitizeSafe(input("New area name:","Blueprint Editing", ""), MAX_NAME_LEN) if(!str || !length(str)) //cancel return if(length(str) > 50) @@ -154,7 +154,7 @@ move an amendment to the drawing.

    var/area/A = get_area() //world << "DEBUG: edit_area" var/prevname = "[A.name]" - var/str = trim(stripped_input(usr,"New area name:","Blueprint Editing", prevname, MAX_NAME_LEN)) + var/str = sanitizeSafe(input("New area name:","Blueprint Editing", prevname), MAX_NAME_LEN) if(!str || !length(str) || str==prevname) //cancel return if(length(str) > 50) diff --git a/code/game/objects/items/devices/PDA/PDA.dm b/code/game/objects/items/devices/PDA/PDA.dm index 0bc2139ae7..6dd7281b4f 100755 --- a/code/game/objects/items/devices/PDA/PDA.dm +++ b/code/game/objects/items/devices/PDA/PDA.dm @@ -689,7 +689,7 @@ var/global/list/obj/item/device/pda/PDAs = list() if ("Edit") var/n = input(U, "Please enter message", name, notehtml) as message if (in_range(src, U) && loc == U) - n = copytext(adminscrub(n), 1, MAX_MESSAGE_LEN) + n = sanitizeSafe(n, extra = 0) if (mode == 1) note = html_decode(n) notehtml = note @@ -972,7 +972,8 @@ var/global/list/obj/item/device/pda/PDAs = list() U.last_target_click = world.time var/t = input(U, "Please enter message", P.name, null) as text t = sanitize(t) - t = readd_quotes(t) + //t = readd_quotes(t) + t = replace_characters(t, list(""" = "\"")) if (!t || !istype(P)) return if (!in_range(src, U) && loc != U) diff --git a/code/game/objects/items/robot/robot_parts.dm b/code/game/objects/items/robot/robot_parts.dm index cfd50c37d5..8deb8d7a50 100644 --- a/code/game/objects/items/robot/robot_parts.dm +++ b/code/game/objects/items/robot/robot_parts.dm @@ -233,7 +233,7 @@ user << "\blue The MMI must go in after everything else!" if (istype(W, /obj/item/weapon/pen)) - var/t = stripped_input(user, "Enter new robot name", src.name, src.created_name, MAX_NAME_LEN) + var/t = sanitizeSafe(input(user, "Enter new robot name", src.name, src.created_name), MAX_NAME_LEN) if (!t) return if (!in_range(src, usr) && src.loc != usr) diff --git a/code/game/objects/items/robot/robot_upgrades.dm b/code/game/objects/items/robot/robot_upgrades.dm index 3f11eb4bbe..43b852e249 100644 --- a/code/game/objects/items/robot/robot_upgrades.dm +++ b/code/game/objects/items/robot/robot_upgrades.dm @@ -53,7 +53,7 @@ var/heldname = "default name" /obj/item/borg/upgrade/rename/attack_self(mob/user as mob) - heldname = stripped_input(user, "Enter new robot name", "Robot Reclassification", heldname, MAX_NAME_LEN) + heldname = sanitizeSafe(input(user, "Enter new robot name", "Robot Reclassification", heldname), MAX_NAME_LEN) /obj/item/borg/upgrade/rename/action(var/mob/living/silicon/robot/R) if(..()) return 0 diff --git a/code/game/objects/items/weapons/AI_modules.dm b/code/game/objects/items/weapons/AI_modules.dm index 9d47d2b08b..7c1e5b6a40 100755 --- a/code/game/objects/items/weapons/AI_modules.dm +++ b/code/game/objects/items/weapons/AI_modules.dm @@ -98,7 +98,7 @@ AI MODULES /obj/item/weapon/aiModule/safeguard/attack_self(var/mob/user as mob) ..() - var/targName = stripped_input(usr, "Please enter the name of the person to safeguard.", "Safeguard who?", user.name) + var/targName = sanitize(input("Please enter the name of the person to safeguard.", "Safeguard who?", user.name)) targetName = targName desc = text("A 'safeguard' AI module: 'Safeguard []. Individuals that threaten [] are not human and are a threat to humans.'", targetName, targetName) @@ -127,7 +127,7 @@ AI MODULES /obj/item/weapon/aiModule/oneHuman/attack_self(var/mob/user as mob) ..() - var/targName = stripped_input(usr, "Please enter the name of the person who is the only human.", "Who?", user.real_name) + var/targName = sanitize(input("Please enter the name of the person who is the only human.", "Who?", user.real_name)) targetName = targName desc = text("A 'one human' AI module: 'Only [] is human.'", targetName) @@ -378,7 +378,7 @@ AI MODULES /obj/item/weapon/aiModule/freeformcore/attack_self(var/mob/user as mob) ..() var/newlaw = "" - var/targName = stripped_input(usr, "Please enter a new core law for the AI.", "Freeform Law Entry", newlaw) + var/targName = sanitize(input("Please enter a new core law for the AI.", "Freeform Law Entry", newlaw)) newFreeFormLaw = targName desc = "A 'freeform' Core AI module: '[newFreeFormLaw]'" @@ -403,7 +403,7 @@ AI MODULES /obj/item/weapon/aiModule/syndicate/attack_self(var/mob/user as mob) ..() var/newlaw = "" - var/targName = stripped_input(usr, "Please enter a new law for the AI.", "Freeform Law Entry", newlaw,MAX_MESSAGE_LEN) + var/targName = sanitize(input("Please enter a new law for the AI.", "Freeform Law Entry", newlaw)) newFreeFormLaw = targName desc = "A hacked AI law module: '[newFreeFormLaw]'" diff --git a/code/game/objects/items/weapons/cards_ids.dm b/code/game/objects/items/weapons/cards_ids.dm index 9ad9b23f75..6a1ee735f4 100644 --- a/code/game/objects/items/weapons/cards_ids.dm +++ b/code/game/objects/items/weapons/cards_ids.dm @@ -224,7 +224,7 @@ /obj/item/weapon/card/id/syndicate/attack_self(mob/user as mob) if(!src.registered_name) //Stop giving the players unsanitized unputs! You are giving ways for players to intentionally crash clients! -Nodrak - var t = reject_bad_name(input(user, "What name would you like to put on this card?", "Agent card name", ishuman(user) ? user.real_name : user.name)) + var t = sanitizeName(input(user, "What name would you like to put on this card?", "Agent card name", ishuman(user) ? user.real_name : user.name)) if(!t) //Same as mob/new_player/prefrences.dm alert("Invalid name.") return diff --git a/code/game/objects/items/weapons/circuitboards/computer/camera_monitor.dm b/code/game/objects/items/weapons/circuitboards/computer/camera_monitor.dm index ff33485f72..e45f51a088 100644 --- a/code/game/objects/items/weapons/circuitboards/computer/camera_monitor.dm +++ b/code/game/objects/items/weapons/circuitboards/computer/camera_monitor.dm @@ -52,7 +52,7 @@ user << "\red Circuit controls are locked." return var/existing_networks = list2text(network,",") - var/input = strip_html(input(usr, "Which networks would you like to connect this camera console circuit to? Seperate networks with a comma. No Spaces!\nFor example: SS13,Security,Secret ", "Multitool-Circuitboard interface", existing_networks)) + var/input = sanitize(input(usr, "Which networks would you like to connect this camera console circuit to? Seperate networks with a comma. No Spaces!\nFor example: SS13,Security,Secret ", "Multitool-Circuitboard interface", existing_networks)) if(!input) usr << "No input found please hang up and try your call again." return diff --git a/code/game/objects/items/weapons/implants/implant.dm b/code/game/objects/items/weapons/implants/implant.dm index c7c7e762ab..ea3b7d5752 100644 --- a/code/game/objects/items/weapons/implants/implant.dm +++ b/code/game/objects/items/weapons/implants/implant.dm @@ -152,7 +152,7 @@ Implant Specifics:
    "} hear(var/msg) var/list/replacechars = list("'" = "","\"" = "",">" = "","<" = "","(" = "",")" = "") - msg = sanitize_simple(msg, replacechars) + msg = replace_characters(msg, replacechars) if(findtext(msg,phrase)) activate() del(src) @@ -206,7 +206,7 @@ Implant Specifics:
    "} elevel = alert("What sort of explosion would you prefer?", "Implant Intent", "Localized Limb", "Destroy Body", "Full Explosion") phrase = input("Choose activation phrase:") as text var/list/replacechars = list("'" = "","\"" = "",">" = "","<" = "","(" = "",")" = "") - phrase = sanitize_simple(phrase, replacechars) + phrase = replace_characters(phrase, replacechars) usr.mind.store_memory("Explosive implant in [source] can be activated by saying something containing the phrase ''[src.phrase]'', say [src.phrase] to attempt to activate.", 0, 0) usr << "The implanted explosive implant in [source] can be activated by saying something containing the phrase ''[src.phrase]'', say [src.phrase] to attempt to activate." return 1 diff --git a/code/game/objects/structures/door_assembly.dm b/code/game/objects/structures/door_assembly.dm index ec55e6549e..1b92926acd 100644 --- a/code/game/objects/structures/door_assembly.dm +++ b/code/game/objects/structures/door_assembly.dm @@ -135,7 +135,7 @@ /obj/structure/door_assembly/attackby(obj/item/W as obj, mob/user as mob) if(istype(W, /obj/item/weapon/pen)) - var/t = copytext(stripped_input(user, "Enter the name for the door.", src.name, src.created_name),1,MAX_NAME_LEN) + var/t = sanitizeSafe(input(user, "Enter the name for the door.", src.name, src.created_name), MAX_NAME_LEN) if(!t) return if(!in_range(src, usr) && src.loc != usr) return created_name = t diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index bbee0157d6..f956743dfa 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -728,7 +728,7 @@ var/global/floorIsLava = 0 var/message = input("Global message to send:", "Admin Announce", null, null) as message if(message) if(!check_rights(R_SERVER,0)) - message = adminscrub(message,500) + message = sanitize(message, 500, extra = 0) world << "\blue [usr.client.holder.fakekey ? "Administrator" : usr.key] Announces:\n \t [message]" log_admin("Announce: [key_name(usr)] : [message]") feedback_add_details("admin_verb","A") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 5fb0d5f231..3751b51277 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -708,7 +708,7 @@ var/list/admin_verbs_mentor = list( return if(holder) - var/new_name = trim_strip_input(src, "Enter new name. Leave blank or as is to cancel.", "Enter new silicon name", S.real_name) + var/new_name = sanitizeSafe(input(src, "Enter new name. Leave blank or as is to cancel.", "Enter new silicon name", S.real_name)) if(new_name && new_name != S.real_name) admin_log_and_message_admins("has renamed the silicon '[S.real_name]' to '[new_name]'") S.SetName(new_name) diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index b40d441ef2..e8817031fe 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -2426,9 +2426,7 @@ src.access_news_network() else if(href_list["ac_set_channel_name"]) - src.admincaster_feed_channel.channel_name = strip_html_simple(input(usr, "Provide a Feed Channel Name", "Network Channel Handler", "")) - while (findtext(src.admincaster_feed_channel.channel_name," ") == 1) - src.admincaster_feed_channel.channel_name = copytext(src.admincaster_feed_channel.channel_name,2,lentext(src.admincaster_feed_channel.channel_name)+1) + src.admincaster_feed_channel.channel_name = sanitizeSafe(input(usr, "Provide a Feed Channel Name", "Network Channel Handler", "")) src.access_news_network() else if(href_list["ac_set_channel_lock"]) @@ -2461,13 +2459,11 @@ var/list/available_channels = list() for(var/datum/feed_channel/F in news_network.network_channels) available_channels += F.channel_name - src.admincaster_feed_channel.channel_name = adminscrub(input(usr, "Choose receiving Feed Channel", "Network Channel Handler") in available_channels ) + src.admincaster_feed_channel.channel_name = sanitizeSafe(input(usr, "Choose receiving Feed Channel", "Network Channel Handler") in available_channels ) src.access_news_network() else if(href_list["ac_set_new_message"]) - src.admincaster_feed_message.body = adminscrub(input(usr, "Write your Feed story", "Network Channel Handler", "")) - while (findtext(src.admincaster_feed_message.body," ") == 1) - src.admincaster_feed_message.body = copytext(src.admincaster_feed_message.body,2,lentext(src.admincaster_feed_message.body)+1) + src.admincaster_feed_message.body = sanitize(input(usr, "Write your Feed story", "Network Channel Handler", "")) src.access_news_network() else if(href_list["ac_submit_new_message"]) @@ -2509,15 +2505,11 @@ src.access_news_network() else if(href_list["ac_set_wanted_name"]) - src.admincaster_feed_message.author = adminscrub(input(usr, "Provide the name of the Wanted person", "Network Security Handler", "")) - while (findtext(src.admincaster_feed_message.author," ") == 1) - src.admincaster_feed_message.author = copytext(admincaster_feed_message.author,2,lentext(admincaster_feed_message.author)+1) + src.admincaster_feed_message.author = sanitize(input(usr, "Provide the name of the Wanted person", "Network Security Handler", "")) src.access_news_network() else if(href_list["ac_set_wanted_desc"]) - src.admincaster_feed_message.body = adminscrub(input(usr, "Provide the a description of the Wanted person and any other details you deem important", "Network Security Handler", "")) - while (findtext(src.admincaster_feed_message.body," ") == 1) - src.admincaster_feed_message.body = copytext(src.admincaster_feed_message.body,2,lentext(src.admincaster_feed_message.body)+1) + src.admincaster_feed_message.body = sanitize(input(usr, "Provide the a description of the Wanted person and any other details you deem important", "Network Security Handler", "")) src.access_news_network() else if(href_list["ac_submit_wanted"]) @@ -2622,7 +2614,7 @@ src.access_news_network() else if(href_list["ac_set_signature"]) - src.admincaster_signature = adminscrub(input(usr, "Provide your desired signature", "Network Identity Handler", "")) + src.admincaster_signature = sanitize(input(usr, "Provide your desired signature", "Network Identity Handler", "")) src.access_news_network() else if(href_list["populate_inactive_customitems"]) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 942cb9c107..7b969a332b 100755 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -1205,7 +1205,7 @@ datum/preferences if("name") var/raw_name = input(user, "Choose your character's name:", "Character Preference") as text|null if (!isnull(raw_name)) // Check to ensure that the user entered text (rather than cancel.) - var/new_name = reject_bad_name(raw_name) + var/new_name = sanitizeName(raw_name) if(new_name) real_name = new_name else diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 76b25c9659..f3d46739f2 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -187,7 +187,7 @@ //Sanitize metadata = sanitize_text(metadata, initial(metadata)) - real_name = reject_bad_name(real_name) + real_name = sanitizeName(real_name) if(isnull(species) || !(species in playable_species)) species = "Human" diff --git a/code/modules/detectivework/scanning_console.dm b/code/modules/detectivework/scanning_console.dm index d9f3ac4df9..2dac51082d 100644 --- a/code/modules/detectivework/scanning_console.dm +++ b/code/modules/detectivework/scanning_console.dm @@ -222,7 +222,7 @@ if("logout") authenticated = 0 if("filter") - var/filterstr = stripped_input(usr,"Input the search criteria. Multiple values can be input, separated by a comma.", "Filter setting") as text|null + var/filterstr = sanitize(input("Input the search criteria. Multiple values can be input, separated by a comma.", "Filter setting") as text|null) if(filterstr) filters[href_list["filter"]] = text2list(filterstr,",") else @@ -243,7 +243,7 @@ current = null if("label") if(current) - var/label = stripped_input(usr,"Input the label for this record. Multiple values can be input, separated by a comma.", "Labeling record", current.fields["label"]) as text|null + var/label = sanitize(input(usr,"Input the label for this record. Multiple values can be input, separated by a comma.", "Labeling record", current.fields["label"]) as text|null) current.fields["label"] = label if("object") if(scanning) diff --git a/code/modules/library/lib_items.dm b/code/modules/library/lib_items.dm index 04906983e1..279be15775 100644 --- a/code/modules/library/lib_items.dm +++ b/code/modules/library/lib_items.dm @@ -31,11 +31,11 @@ O.loc = src update_icon() else if(istype(O, /obj/item/weapon/pen)) - var/newname = stripped_input(usr, "What would you like to title this bookshelf?") + var/newname = sanitizeSafe(input("What would you like to title this bookshelf?"), MAX_MESSAGE_LEN) if(!newname) return else - name = ("bookcase ([sanitizeSafe(newname)])") + name = ("bookcase ([newname])") else ..() @@ -174,7 +174,7 @@ var/choice = input("What would you like to change?") in list("Title", "Contents", "Author", "Cancel") switch(choice) if("Title") - var/newtitle = reject_bad_text(stripped_input(usr, "Write a new title:")) + var/newtitle = reject_bad_text(sanitizeSafe(input("Write a new title:"))) if(!newtitle) usr << "The title is invalid." return @@ -182,14 +182,14 @@ src.name = newtitle src.title = newtitle if("Contents") - var/content = strip_html(input(usr, "Write your book's contents (HTML NOT allowed):"),8192) as message|null + var/content = sanitize(input("Write your book's contents (HTML NOT allowed):") as message|null, MAX_BOOK_MESSAGE_LEN) if(!content) usr << "The content is invalid." return else src.dat += content if("Author") - var/newauthor = stripped_input(usr, "Write the author's name:") + var/newauthor = sanitize(input(usr, "Write the author's name:")) if(!newauthor) usr << "The name is invalid." return diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index d352ee93a7..7b5f740135 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -533,7 +533,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp var/max_length = 50 - var/message = stripped_input(src,"Write a message. It cannot be longer than [max_length] characters.","Blood writing", "") + var/message = sanitize(input("Write a message. It cannot be longer than [max_length] characters.","Blood writing", "")) if (message) diff --git a/code/modules/mob/dead/observer/say.dm b/code/modules/mob/dead/observer/say.dm index b5b819950c..be9f1615e0 100644 --- a/code/modules/mob/dead/observer/say.dm +++ b/code/modules/mob/dead/observer/say.dm @@ -1,5 +1,5 @@ /mob/dead/observer/say(var/message) - message = strip_html_properly(message) + message = sanitize(message) if (!message) return @@ -18,7 +18,7 @@ /mob/dead/observer/emote(var/act, var/type, var/message) - message = trim_strip_html_properly(message) + message = sanitize(message) if(!message) return diff --git a/code/modules/mob/living/carbon/alien/say.dm b/code/modules/mob/living/carbon/alien/say.dm index 038c77fcde..28ae01391f 100644 --- a/code/modules/mob/living/carbon/alien/say.dm +++ b/code/modules/mob/living/carbon/alien/say.dm @@ -7,7 +7,7 @@ src << "\red You cannot speak in IC (Muted)." return - message = trim_strip_html_properly(message) + message = sanitize(message) if(stat == 2) return say_dead(message) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index c3c2110872..3d1304ab55 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1205,7 +1205,7 @@ var/max_length = bloody_hands * 30 //tweeter style - var/message = stripped_input(src,"Write a message. It cannot be longer than [max_length] characters.","Blood writing", "") + var/message = sanitize(input("Write a message. It cannot be longer than [max_length] characters.","Blood writing", "")) if (message) var/used_blood_amount = round(length(message) / 30, 1) diff --git a/code/modules/mob/living/carbon/human/say.dm b/code/modules/mob/living/carbon/human/say.dm index 20c5183d72..120ce2086a 100644 --- a/code/modules/mob/living/carbon/human/say.dm +++ b/code/modules/mob/living/carbon/human/say.dm @@ -10,7 +10,7 @@ src << "\red You cannot speak in IC (Muted)." return - message = trim_strip_html_properly(message) + message = sanitize(message) if(stat) if(stat == 2) diff --git a/code/modules/mob/living/carbon/human/whisper.dm b/code/modules/mob/living/carbon/human/whisper.dm index 0c9882b215..2f67cbec85 100644 --- a/code/modules/mob/living/carbon/human/whisper.dm +++ b/code/modules/mob/living/carbon/human/whisper.dm @@ -6,7 +6,7 @@ usr << "\red Speech is currently admin-disabled." return - message = trim_strip_html_properly(message) + message = sanitize(message) log_whisper("[src.name]/[src.key] : [message]") if (src.client) diff --git a/code/modules/mob/living/silicon/say.dm b/code/modules/mob/living/silicon/say.dm index 9fb93e0eff..ec6ddefe1c 100644 --- a/code/modules/mob/living/silicon/say.dm +++ b/code/modules/mob/living/silicon/say.dm @@ -34,7 +34,7 @@ if (src.client.handle_spam_prevention(message,MUTE_IC)) return 0 - message = trim_strip_html_properly(message) + message = sanitize(message) if (stat == 2) return say_dead(message) diff --git a/code/modules/mob/living/simple_animal/borer/borer_captive.dm b/code/modules/mob/living/simple_animal/borer/borer_captive.dm index eacc058945..156d362773 100644 --- a/code/modules/mob/living/simple_animal/borer/borer_captive.dm +++ b/code/modules/mob/living/simple_animal/borer/borer_captive.dm @@ -14,7 +14,7 @@ if(istype(src.loc,/mob/living/simple_animal/borer)) - message = trim_strip_html_properly(message) + message = sanitize(message) if (!message) return log_say("[key_name(src)] : [message]") diff --git a/code/modules/mob/living/simple_animal/borer/say.dm b/code/modules/mob/living/simple_animal/borer/say.dm index 5b52a5b473..a5e5a34d58 100644 --- a/code/modules/mob/living/simple_animal/borer/say.dm +++ b/code/modules/mob/living/simple_animal/borer/say.dm @@ -1,6 +1,6 @@ /mob/living/simple_animal/borer/say(var/message) - message = trim_strip_html_properly(message) + message = sanitize(message) message = capitalize(message) if(!message) diff --git a/code/modules/mob/say.dm b/code/modules/mob/say.dm index 998c241498..899d0a9c9b 100644 --- a/code/modules/mob/say.dm +++ b/code/modules/mob/say.dm @@ -36,7 +36,7 @@ usr << "\red Speech is currently admin-disabled." return - message = strip_html_properly(message) + message = sanitize(message) set_typing_indicator(0) if(use_me) diff --git a/code/modules/nano/modules/law_manager.dm b/code/modules/nano/modules/law_manager.dm index a152411283..faccc5fdc3 100644 --- a/code/modules/nano/modules/law_manager.dm +++ b/code/modules/nano/modules/law_manager.dm @@ -77,25 +77,25 @@ return 1 if(href_list["change_zeroth_law"]) - var/new_law = trim_strip_input(usr, "Enter new law Zero. Leaving the field blank will cancel the edit.", "Edit Law", zeroth_law) + var/new_law = sanitize(input("Enter new law Zero. Leaving the field blank will cancel the edit.", "Edit Law", zeroth_law)) if(new_law && new_law != zeroth_law && can_still_topic()) zeroth_law = new_law return 1 if(href_list["change_ion_law"]) - var/new_law = trim_strip_input(usr, "Enter new ion law. Leaving the field blank will cancel the edit.", "Edit Law", ion_law) + var/new_law = sanitize(input("Enter new ion law. Leaving the field blank will cancel the edit.", "Edit Law", ion_law)) if(new_law && new_law != ion_law && can_still_topic()) ion_law = new_law return 1 if(href_list["change_inherent_law"]) - var/new_law = trim_strip_input(usr, "Enter new inherent law. Leaving the field blank will cancel the edit.", "Edit Law", inherent_law) + var/new_law = sanitize(input("Enter new inherent law. Leaving the field blank will cancel the edit.", "Edit Law", inherent_law)) if(new_law && new_law != inherent_law && can_still_topic()) inherent_law = new_law return 1 if(href_list["change_supplied_law"]) - var/new_law = trim_strip_input(usr, "Enter new supplied law. Leaving the field blank will cancel the edit.", "Edit Law", supplied_law) + var/new_law = sanitize(input("Enter new supplied law. Leaving the field blank will cancel the edit.", "Edit Law", supplied_law)) if(new_law && new_law != supplied_law && can_still_topic()) supplied_law = new_law return 1 @@ -110,7 +110,7 @@ if(is_malf(usr)) var/datum/ai_law/AL = locate(href_list["edit_law"]) in owner.laws.all_laws() if(AL) - var/new_law = trim_strip_input(usr, "Enter new law. Leaving the field blank will cancel the edit.", "Edit Law", AL.law) + var/new_law = sanitize(input(usr, "Enter new law. Leaving the field blank will cancel the edit.", "Edit Law", AL.law)) if(new_law && new_law != AL.law && is_malf(usr) && can_still_topic()) log_and_message_admins("has changed a law of [owner] from '[AL.law]' to '[new_law]'") AL.law = new_law diff --git a/code/modules/paperwork/pen.dm b/code/modules/paperwork/pen.dm index 18ff946cc8..3c3d07b36f 100644 --- a/code/modules/paperwork/pen.dm +++ b/code/modules/paperwork/pen.dm @@ -130,7 +130,7 @@ if(new_signature) signature = new_signature */ - signature = trim_strip_html_properly(input("Enter new signature. Leave blank for 'Anonymous'", "New Signature", signature)) + signature = sanitize(input("Enter new signature. Leave blank for 'Anonymous'", "New Signature", signature)) /obj/item/weapon/pen/proc/get_signature(var/mob/user) return (user && user.real_name) ? user.real_name : "Anonymous" diff --git a/code/modules/projectiles/guns/projectile/pistol.dm b/code/modules/projectiles/guns/projectile/pistol.dm index f2155fa669..adbf30922d 100644 --- a/code/modules/projectiles/guns/projectile/pistol.dm +++ b/code/modules/projectiles/guns/projectile/pistol.dm @@ -22,7 +22,7 @@ M << "You don't feel cool enough to name this gun, chump." return 0 - var/input = stripped_input(usr,"What do you want to name the gun?", ,"", MAX_NAME_LEN) + var/input = sanitizeSafe(input("What do you want to name the gun?", ,""), MAX_NAME_LEN) if(src && input && !M.stat && in_range(M,src)) name = input diff --git a/code/modules/projectiles/guns/projectile/revolver.dm b/code/modules/projectiles/guns/projectile/revolver.dm index 9bef0c40d3..fb5895aad9 100644 --- a/code/modules/projectiles/guns/projectile/revolver.dm +++ b/code/modules/projectiles/guns/projectile/revolver.dm @@ -34,7 +34,7 @@ M << "You don't feel cool enough to name this gun, chump." return 0 - var/input = stripped_input(usr,"What do you want to name the gun?", ,"", MAX_NAME_LEN) + var/input = sanitizeSafe(input("What do you want to name the gun?", ,""), MAX_NAME_LEN) if(src && input && !M.stat && in_range(M,src)) name = input diff --git a/code/modules/reagents/Chemistry-Machinery.dm b/code/modules/reagents/Chemistry-Machinery.dm index 2fab30fe45..c23927cca9 100644 --- a/code/modules/reagents/Chemistry-Machinery.dm +++ b/code/modules/reagents/Chemistry-Machinery.dm @@ -435,7 +435,7 @@ src.updateUsrDialog() return else if(href_list["name_disease"]) - var/new_name = stripped_input(usr, "Name the Disease", "New Name", "", MAX_NAME_LEN) + var/new_name = sanitizeSafe(input(usr, "Name the Disease", "New Name", ""), MAX_NAME_LEN) if(stat & (NOPOWER|BROKEN)) return if(usr.stat || usr.restrained()) return if(!in_range(src, usr)) return From 5fee41d4ba4aa72ad9008fd1fdffdb62491d2015 Mon Sep 17 00:00:00 2001 From: volas Date: Wed, 25 Mar 2015 01:05:21 +0300 Subject: [PATCH 4/5] sanitize() refactor: third pass (misc) --- code/controllers/voting.dm | 4 +- code/datums/diseases/advance/advance.dm | 2 +- code/game/machinery/computer/message.dm | 4 +- .../machinery/computer3/computers/medical.dm | 2 +- .../machinery/computer3/computers/security.dm | 2 +- code/game/machinery/requests_console.dm | 4 +- code/game/response_team.dm | 2 +- code/modules/admin/DB ban/functions.dm | 2 +- code/modules/admin/admin.dm | 2 +- code/modules/admin/admin_memo.dm | 2 +- code/modules/admin/admin_verbs.dm | 2 +- code/modules/admin/topic.dm | 21 ++++----- code/modules/admin/verbs/adminpm.dm | 3 +- code/modules/admin/verbs/custom_event.dm | 6 +-- code/modules/admin/verbs/debug.dm | 2 +- code/modules/admin/verbs/massmodvar.dm | 2 +- code/modules/admin/verbs/modifyvariables.dm | 8 ++-- code/modules/admin/verbs/randomverbs.dm | 12 ++--- code/modules/client/client procs.dm | 2 +- code/modules/client/preferences.dm | 44 ++++--------------- .../spacesuits/rig/modules/utility.dm | 4 +- code/modules/economy/EFTPOS.dm | 4 +- code/modules/events/event_manager.dm | 2 +- code/modules/mob/living/carbon/human/human.dm | 10 +---- .../modules/mob/living/silicon/robot/robot.dm | 4 +- .../mob/living/silicon/robot/robot_items.dm | 4 +- code/modules/mob/mob.dm | 5 +-- code/modules/reagents/Chemistry-Machinery.dm | 4 +- .../reagent_containers/food/snacks.dm | 2 +- .../research/xenoarchaeology/chemistry.dm | 2 +- .../xenoarchaeology/finds/finds_fossils.dm | 2 +- 31 files changed, 68 insertions(+), 103 deletions(-) diff --git a/code/controllers/voting.dm b/code/controllers/voting.dm index 34658944bc..7db31c6fa6 100644 --- a/code/controllers/voting.dm +++ b/code/controllers/voting.dm @@ -241,10 +241,10 @@ datum/controller/vote choices.Add(antag.role_text) choices.Add("None") if("custom") - question = html_encode(input(usr,"What is the vote for?") as text|null) + question = sanitizeSafe(input(usr,"What is the vote for?") as text|null) if(!question) return 0 for(var/i=1,i<=10,i++) - var/option = capitalize(html_encode(input(usr,"Please enter an option or hit cancel to finish") as text|null)) + var/option = capitalize(sanitize(input(usr,"Please enter an option or hit cancel to finish") as text|null)) if(!option || mode || !usr.client) break choices.Add(option) else diff --git a/code/datums/diseases/advance/advance.dm b/code/datums/diseases/advance/advance.dm index bea5672006..70acceca35 100644 --- a/code/datums/diseases/advance/advance.dm +++ b/code/datums/diseases/advance/advance.dm @@ -394,7 +394,7 @@ var/list/advance_cures = list( if(D.symptoms.len > 0) - var/new_name = input(user, "Name your new disease.", "New Name") + var/new_name = sanitizeSafe(input(user, "Name your new disease.", "New Name"), MAX_NAME_LEN) D.AssignName(new_name) D.Refresh() diff --git a/code/game/machinery/computer/message.dm b/code/game/machinery/computer/message.dm index d11e606776..94eadf7f11 100644 --- a/code/game/machinery/computer/message.dm +++ b/code/game/machinery/computer/message.dm @@ -409,7 +409,7 @@ //Select Your Name if("Sender") - customsender = input(usr, "Please enter the sender's name.") as text|null + customsender = sanitize(input(usr, "Please enter the sender's name.") as text|null) //Select Receiver if("Recepient") @@ -425,7 +425,7 @@ //Enter custom job if("RecJob") - customjob = input(usr, "Please enter the sender's job.") as text|null + customjob = sanitize(input(usr, "Please enter the sender's job.") as text|null) //Enter message if("Message") diff --git a/code/game/machinery/computer3/computers/medical.dm b/code/game/machinery/computer3/computers/medical.dm index 96b1ccad5b..adb7ff9079 100644 --- a/code/game/machinery/computer3/computers/medical.dm +++ b/code/game/machinery/computer3/computers/medical.dm @@ -330,7 +330,7 @@ src.active2.fields["cdi_d"] = t1 if("notes") if (istype(src.active2, /datum/data/record)) - var/t1 = html_encode(trim(copytext(input("Please summarize notes:", "Med. records", html_decode(src.active2.fields["notes"]), null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize notes:", "Med. records", html_decode(src.active2.fields["notes"]), null) as message, extra = 0) if ((!( t1 ) || !( src.authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || src.active2 != a2)) return src.active2.fields["notes"] = t1 diff --git a/code/game/machinery/computer3/computers/security.dm b/code/game/machinery/computer3/computers/security.dm index e00aab556d..924f32b1b7 100644 --- a/code/game/machinery/computer3/computers/security.dm +++ b/code/game/machinery/computer3/computers/security.dm @@ -498,7 +498,7 @@ What a mess.*/ active2.fields["ma_crim_d"] = t1 if("notes") if (istype(active2, /datum/data/record)) - var/t1 = html_encode(trim(copytext(input("Please summarize notes:", "Secure. records", html_decode(active2.fields["notes"]), null) as message,1,MAX_MESSAGE_LEN))) + var/t1 = sanitize(input("Please summarize notes:", "Secure. records", html_decode(active2.fields["notes"]), null) as message, extra = 0) if ((!( t1 ) || !( authenticated ) || usr.stat || usr.restrained() || (!interactable() && (!istype(usr, /mob/living/silicon))) || active2 != a2)) return active2.fields["notes"] = t1 diff --git a/code/game/machinery/requests_console.dm b/code/game/machinery/requests_console.dm index f9dd2216df..3c7e1613b9 100644 --- a/code/game/machinery/requests_console.dm +++ b/code/game/machinery/requests_console.dm @@ -223,7 +223,7 @@ var/list/obj/machinery/requests_console/allConsoles = list() if(reject_bad_text(href_list["write"])) dpt = ckey(href_list["write"]) //write contains the string of the receiving department's name - var/new_message = copytext(reject_bad_text(input(usr, "Write your message:", "Awaiting Input", "")),1,MAX_MESSAGE_LEN) + var/new_message = sanitize(input("Write your message:", "Awaiting Input", "")) if(new_message) message = new_message screen = 9 @@ -238,7 +238,7 @@ var/list/obj/machinery/requests_console/allConsoles = list() priority = -1 if(href_list["writeAnnouncement"]) - var/new_message = copytext(reject_bad_text(input(usr, "Write your message:", "Awaiting Input", "")),1,MAX_MESSAGE_LEN) + var/new_message = sanitize(input("Write your message:", "Awaiting Input", "")) if(new_message) message = new_message switch(href_list["priority"]) diff --git a/code/game/response_team.dm b/code/game/response_team.dm index ea1a03a571..a64230b1d6 100644 --- a/code/game/response_team.dm +++ b/code/game/response_team.dm @@ -53,7 +53,7 @@ client/verb/JoinResponseTeam() for (var/obj/effect/landmark/L in landmarks_list) if (L.name == "Commando") L.name = null//Reserving the place. - var/new_name = input(usr, "Pick a name","Name") as null|text + var/new_name = sanitizeSafe(input(usr, "Pick a name","Name") as null|text, MAX_NAME_LEN) if(!new_name)//Somebody changed his mind, place is available again. L.name = "Commando" return diff --git a/code/modules/admin/DB ban/functions.dm b/code/modules/admin/DB ban/functions.dm index 32e633a200..a361328cac 100644 --- a/code/modules/admin/DB ban/functions.dm +++ b/code/modules/admin/DB ban/functions.dm @@ -181,7 +181,7 @@ datum/admins/proc/DB_ban_edit(var/banid = null, var/param = null) switch(param) if("reason") if(!value) - value = input("Insert the new reason for [pckey]'s ban", "New Reason", "[reason]", null) as null|text + value = sanitize(input("Insert the new reason for [pckey]'s ban", "New Reason", "[reason]", null) as null|text) value = sql_sanitize_text(value) if(!value) usr << "Cancelled" diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index f956743dfa..57cdcd479a 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -725,7 +725,7 @@ var/global/floorIsLava = 0 set desc="Announce your desires to the world" if(!check_rights(0)) return - var/message = input("Global message to send:", "Admin Announce", null, null) as message + var/message = input("Global message to send:", "Admin Announce", null, null) as message//todo: sanitize for all? if(message) if(!check_rights(R_SERVER,0)) message = sanitize(message, 500, extra = 0) diff --git a/code/modules/admin/admin_memo.dm b/code/modules/admin/admin_memo.dm index 133f6d10e9..4bcaf10d9c 100644 --- a/code/modules/admin/admin_memo.dm +++ b/code/modules/admin/admin_memo.dm @@ -16,7 +16,7 @@ /client/proc/admin_memo_write() var/savefile/F = new(MEMOFILE) if(F) - var/memo = input(src,"Type your memo\n(Leaving it blank will delete your current memo):","Write Memo",null) as null|message + var/memo = sanitize(input(src,"Type your memo\n(Leaving it blank will delete your current memo):","Write Memo",null) as null|message, extra = 0) switch(memo) if(null) return diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 3751b51277..648e8551a2 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -616,7 +616,7 @@ var/list/admin_verbs_mentor = list( set name = "Make Sound" set desc = "Display a message to everyone who can hear the target" if(O) - var/message = input("What do you want the message to be?", "Make Sound") as text|null + var/message = sanitize(input("What do you want the message to be?", "Make Sound") as text|null) if(!message) return for (var/mob/V in hearers(O)) diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index e8817031fe..ec16a37d25 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -328,12 +328,12 @@ mins = min(525599,mins) minutes = CMinutes + mins duration = GetExp(minutes) - reason = input(usr,"Reason?","reason",reason2) as text|null + reason = sanitize(input(usr,"Reason?","reason",reason2) as text|null) if(!reason) return if("No") temp = 0 duration = "Perma" - reason = input(usr,"Reason?","reason",reason2) as text|null + reason = sanitize(input(usr,"Reason?","reason",reason2) as text|null) if(!reason) return log_admin("[key_name(usr)] edited [banned_key]'s ban. Reason: [reason] Duration: [duration]") @@ -655,7 +655,7 @@ var/mins = input(usr,"How long (in minutes)?","Ban time",1440) as num|null if(!mins) return - var/reason = input(usr,"Reason?","Please State Reason","") as text|null + var/reason = sanitize(input(usr,"Reason?","Please State Reason","") as text|null) if(!reason) return @@ -680,7 +680,7 @@ return 1 if("No") if(!check_rights(R_BAN)) return - var/reason = input(usr,"Reason?","Please State Reason","") as text|null + var/reason = sanitize(input(usr,"Reason?","Please State Reason","") as text|null) if(reason) var/msg for(var/job in notbannedlist) @@ -737,7 +737,7 @@ if (ismob(M)) if(!check_if_greater_rights_than(M.client)) return - var/reason = input("Please enter reason") + var/reason = sanitize(input("Please enter reason")) if(!reason) M << "\red You have been kicked from the server" else @@ -794,7 +794,7 @@ if(!mins) return if(mins >= 525600) mins = 525599 - var/reason = input(usr,"Reason?","reason","Griefer") as text|null + var/reason = sanitize(input(usr,"Reason?","reason","Griefer") as text|null) if(!reason) return AddBan(M.ckey, M.computer_id, reason, usr.ckey, 1, mins) @@ -815,7 +815,7 @@ //del(M) // See no reason why to delete mob. Important stuff can be lost. And ban can be lifted before round ends. if("No") if(!check_rights(R_BAN)) return - var/reason = input(usr,"Reason?","reason","Griefer") as text|null + var/reason = sanitize(input(usr,"Reason?","reason","Griefer") as text|null) if(!reason) return switch(alert(usr,"IP ban?",,"Yes","No","Cancel")) @@ -1379,7 +1379,7 @@ usr << "The person you are trying to contact is not wearing a headset" return - var/input = input(src.owner, "Please enter a message to reply to [key_name(H)] via their headset.","Outgoing message from Centcomm", "") + var/input = sanitize(input(src.owner, "Please enter a message to reply to [key_name(H)] via their headset.","Outgoing message from Centcomm", "")) if(!input) return src.owner << "You sent [input] to [H] via a secure channel." @@ -1396,7 +1396,7 @@ usr << "The person you are trying to contact is not wearing a headset" return - var/input = input(src.owner, "Please enter a message to reply to [key_name(H)] via their headset.","Outgoing message from a shadowy figure...", "") + var/input = sanitize(input(src.owner, "Please enter a message to reply to [key_name(H)] via their headset.","Outgoing message from a shadowy figure...", "")) if(!input) return src.owner << "You sent [input] to [H] via a secure channel." @@ -1443,6 +1443,7 @@ var/mob/sender = locate(href_list["CentcommFaxReply"]) var/obj/machinery/photocopier/faxmachine/fax = locate(href_list["originfax"]) + //todo: sanitize var/input = input(src.owner, "Please enter a message to reply to [key_name(sender)] via secure connection. NOTE: BBCode does not work, but HTML tags do! Use
    for line breaks.", "Outgoing message from Centcomm", "") as message|null if(!input) return @@ -2652,7 +2653,7 @@ if(href_list["add_player_info"]) var/key = href_list["add_player_info"] - var/add = input("Add Player Info") as null|text + var/add = sanitize(input("Add Player Info") as null|text) if(!add) return notes_add(key,add,usr) diff --git a/code/modules/admin/verbs/adminpm.dm b/code/modules/admin/verbs/adminpm.dm index 9d13437faa..467083e827 100644 --- a/code/modules/admin/verbs/adminpm.dm +++ b/code/modules/admin/verbs/adminpm.dm @@ -60,6 +60,7 @@ return //clean the message if it's not sent by a high-rank admin + //todo: sanitize for all??? if(!check_rights(R_SERVER|R_DEBUG,0)) msg = sanitize(msg) if(!msg) return @@ -91,7 +92,7 @@ spawn(0) //so we don't hold the caller proc up var/sender = src var/sendername = key - var/reply = input(C, msg,"[recieve_pm_type] PM from [sendername]", "") as text|null //show message and await a reply + var/reply = sanitize(input(C, msg,"[recieve_pm_type] PM from [sendername]", "") as text|null) //show message and await a reply if(C && reply) if(sender) C.cmd_admin_pm(sender,reply) //sender is still about, let's reply to them diff --git a/code/modules/admin/verbs/custom_event.dm b/code/modules/admin/verbs/custom_event.dm index 3021cc2828..265c16a868 100644 --- a/code/modules/admin/verbs/custom_event.dm +++ b/code/modules/admin/verbs/custom_event.dm @@ -7,7 +7,7 @@ src << "Only administrators may use this command." return - var/input = input(usr, "Enter the description of the custom event. Be descriptive. To cancel the event, make this blank or hit cancel.", "Custom Event", custom_event_msg) as message|null + var/input = sanitize(input(usr, "Enter the description of the custom event. Be descriptive. To cancel the event, make this blank or hit cancel.", "Custom Event", custom_event_msg) as message|null, MAX_BOOK_MESSAGE_LEN, extra = 0) if(!input || input == "") custom_event_msg = null log_admin("[usr.key] has cleared the custom event text.") @@ -21,7 +21,7 @@ world << "

    Custom Event

    " world << "

    A custom event is starting. OOC Info:

    " - world << "[html_encode(custom_event_msg)]" + world << "[custom_event_msg]" world << "
    " // normal verb for players to view info @@ -36,5 +36,5 @@ src << "

    Custom Event

    " src << "

    A custom event is taking place. OOC Info:

    " - src << "[html_encode(custom_event_msg)]" + src << "[custom_event_msg]" src << "
    " diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 4e4ed552d2..b9858aa7d5 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -205,7 +205,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that return 0 var/obj/item/device/paicard/card = new(T) var/mob/living/silicon/pai/pai = new(card) - pai.name = input(choice, "Enter your pAI name:", "pAI Name", "Personal AI") as text + pai.name = sanitizeSafe(input(choice, "Enter your pAI name:", "pAI Name", "Personal AI") as text) pai.real_name = pai.name pai.key = choice.key card.setPersonality(pai) diff --git a/code/modules/admin/verbs/massmodvar.dm b/code/modules/admin/verbs/massmodvar.dm index a35fb15174..a6b4bf7d16 100644 --- a/code/modules/admin/verbs/massmodvar.dm +++ b/code/modules/admin/verbs/massmodvar.dm @@ -168,7 +168,7 @@ return .(O.vars[variable]) if("text") - var/new_value = input("Enter new text:","Text",O.vars[variable]) as text|null + var/new_value = input("Enter new text:","Text",O.vars[variable]) as text|null//todo: sanitize ??? if(new_value == null) return O.vars[variable] = new_value diff --git a/code/modules/admin/verbs/modifyvariables.dm b/code/modules/admin/verbs/modifyvariables.dm index 8c48af6a45..fce2aa59dc 100644 --- a/code/modules/admin/verbs/modifyvariables.dm +++ b/code/modules/admin/verbs/modifyvariables.dm @@ -44,7 +44,7 @@ var/list/forbidden_varedit_object_types = list( switch(class) if("text") - var_value = input("Enter new text:","Text") as null|text + var_value = input("Enter new text:","Text") as null|text//todo: sanitize ??? if("num") var_value = input("Enter new number:","Num") as null|num @@ -93,7 +93,7 @@ var/list/forbidden_varedit_object_types = list( switch(class) if("text") - var_value = input("Enter new text:","Text") as text + var_value = input("Enter new text:","Text") as text//todo: sanitize ??? if("num") var_value = input("Enter new number:","Num") as num @@ -243,7 +243,7 @@ var/list/forbidden_varedit_object_types = list( return if("text") - L[L.Find(variable)] = input("Enter new text:","Text") as text + L[L.Find(variable)] = input("Enter new text:","Text") as text//todo: sanitize ??? if("num") L[L.Find(variable)] = input("Enter new number:","Num") as num @@ -450,7 +450,7 @@ var/list/forbidden_varedit_object_types = list( return .(O.vars[variable]) if("text") - var/var_new = input("Enter new text:","Text",O.vars[variable]) as null|text + var/var_new = input("Enter new text:","Text",O.vars[variable]) as null|text//todo: sanitize ??? if(var_new==null) return O.vars[variable] = var_new diff --git a/code/modules/admin/verbs/randomverbs.dm b/code/modules/admin/verbs/randomverbs.dm index 07d8009219..03b8a03cac 100644 --- a/code/modules/admin/verbs/randomverbs.dm +++ b/code/modules/admin/verbs/randomverbs.dm @@ -52,7 +52,7 @@ src << "Only administrators may use this command." return - var/msg = input("Message:", text("Subtle PM to [M.key]")) as text + var/msg = sanitize(input("Message:", text("Subtle PM to [M.key]")) as text) if (!msg) return @@ -109,7 +109,7 @@ src << "Only administrators may use this command." return - var/msg = input("Message:", text("Enter the text you wish to appear to everyone:")) as text + var/msg = sanitize(input("Message:", text("Enter the text you wish to appear to everyone:")) as text) if (!msg) return @@ -132,7 +132,7 @@ if(!M) return - var/msg = input("Message:", text("Enter the text you wish to appear to your target:")) as text + var/msg = sanitize(input("Message:", text("Enter the text you wish to appear to your target:")) as text) if( !msg ) return @@ -475,7 +475,7 @@ Traitors and the like can also be revived with the previous role mostly intact. if(!holder) src << "Only administrators may use this command." return - var/input = input(usr, "Please enter anything you want the AI to do. Anything. Serious.", "What?", "") as text|null + var/input = sanitize(input(usr, "Please enter anything you want the AI to do. Anything. Serious.", "What?", "") as text|null) if(!input) return for(var/mob/living/silicon/ai/M in mob_list) @@ -523,8 +523,8 @@ Traitors and the like can also be revived with the previous role mostly intact. if(!holder) src << "Only administrators may use this command." return - var/input = input(usr, "Please enter anything you want. Anything. Serious.", "What?", "") as message|null - var/customname = input(usr, "Pick a title for the report.", "Title") as text|null + var/input = sanitize(input(usr, "Please enter anything you want. Anything. Serious.", "What?", "") as message|null, extra = 0) + var/customname = sanitizeSafe(input(usr, "Pick a title for the report.", "Title") as text|null) if(!input) return if(!customname) diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index a8efe68418..45ca127f13 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -145,7 +145,7 @@ if(custom_event_msg && custom_event_msg != "") src << "

    Custom Event

    " src << "

    A custom event is taking place. OOC Info:

    " - src << "[html_encode(custom_event_msg)]" + src << "[custom_event_msg]" src << "
    " if( (world.address == address || !address) && !host ) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 7b969a332b..4466becf74 100755 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -995,16 +995,10 @@ datum/preferences ShowChoices(user) return if("general") - var/msg = input(usr,"Give a general description of your character. This will be shown regardless of clothing, and may include OOC notes and preferences.","Flavor Text",html_decode(flavor_texts[href_list["task"]])) as message - if(msg != null) - msg = copytext(msg, 1, MAX_MESSAGE_LEN) - msg = html_encode(msg) + var/msg = sanitize(input(usr,"Give a general description of your character. This will be shown regardless of clothing, and may include OOC notes and preferences.","Flavor Text",html_decode(flavor_texts[href_list["task"]])) as message, extra = 0) flavor_texts[href_list["task"]] = msg else - var/msg = input(usr,"Set the flavor text for your [href_list["task"]].","Flavor Text",html_decode(flavor_texts[href_list["task"]])) as message - if(msg != null) - msg = copytext(msg, 1, MAX_MESSAGE_LEN) - msg = html_encode(msg) + var/msg = sanitize(input(usr,"Set the flavor text for your [href_list["task"]].","Flavor Text",html_decode(flavor_texts[href_list["task"]])) as message, extra = 0) flavor_texts[href_list["task"]] = msg SetFlavorText(user) return @@ -1019,16 +1013,10 @@ datum/preferences ShowChoices(user) return if("Default") - var/msg = input(usr,"Set the default flavour text for your robot. It will be used for any module without individual setting.","Flavour Text",html_decode(flavour_texts_robot["Default"])) as message - if(msg != null) - msg = copytext(msg, 1, MAX_MESSAGE_LEN) - msg = html_encode(msg) + var/msg = sanitize(input(usr,"Set the default flavour text for your robot. It will be used for any module without individual setting.","Flavour Text",html_decode(flavour_texts_robot["Default"])) as message, extra = 0) flavour_texts_robot[href_list["task"]] = msg else - var/msg = input(usr,"Set the flavour text for your robot with [href_list["task"]] module. If you leave this empty, default flavour text will be used for this module.","Flavour Text",html_decode(flavour_texts_robot[href_list["task"]])) as message - if(msg != null) - msg = copytext(msg, 1, MAX_MESSAGE_LEN) - msg = html_encode(msg) + var/msg = sanitize(input(usr,"Set the flavour text for your robot with [href_list["task"]] module. If you leave this empty, default flavour text will be used for this module.","Flavour Text",html_decode(flavour_texts_robot[href_list["task"]])) as message, extra = 0) flavour_texts_robot[href_list["task"]] = msg SetFlavourTextRobot(user) return @@ -1044,41 +1032,25 @@ datum/preferences else user << browse(null, "window=records") if(href_list["task"] == "med_record") - var/medmsg = input(usr,"Set your medical notes here.","Medical Records",html_decode(med_record)) as message - + var/medmsg = sanitize(input(usr,"Set your medical notes here.","Medical Records",html_decode(med_record)) as message, MAX_PAPER_MESSAGE_LEN, extra = 0) if(medmsg != null) - medmsg = copytext(medmsg, 1, MAX_PAPER_MESSAGE_LEN) - medmsg = html_encode(medmsg) - med_record = medmsg SetRecords(user) if(href_list["task"] == "sec_record") - var/secmsg = input(usr,"Set your security notes here.","Security Records",html_decode(sec_record)) as message - + var/secmsg = sanitize(input(usr,"Set your security notes here.","Security Records",html_decode(sec_record)) as message, MAX_PAPER_MESSAGE_LEN, extra = 0) if(secmsg != null) - secmsg = copytext(secmsg, 1, MAX_PAPER_MESSAGE_LEN) - secmsg = html_encode(secmsg) - sec_record = secmsg SetRecords(user) if(href_list["task"] == "gen_record") - var/genmsg = input(usr,"Set your employment notes here.","Employment Records",html_decode(gen_record)) as message - + var/genmsg = sanitize(input(usr,"Set your employment notes here.","Employment Records",html_decode(gen_record)) as message, MAX_PAPER_MESSAGE_LEN, extra = 0) if(genmsg != null) - genmsg = copytext(genmsg, 1, MAX_PAPER_MESSAGE_LEN) - genmsg = html_encode(genmsg) - gen_record = genmsg SetRecords(user) if(href_list["task"] == "exploitable_record") - var/exploitmsg = input(usr,"Set exploitable information about you here.","Exploitable Information",html_decode(exploit_record)) as message - + var/exploitmsg = sanitize(input(usr,"Set exploitable information about you here.","Exploitable Information",html_decode(exploit_record)) as message, MAX_PAPER_MESSAGE_LEN, extra = 0) if(exploitmsg != null) - exploitmsg = copytext(exploitmsg, 1, MAX_PAPER_MESSAGE_LEN) - exploitmsg = html_encode(exploitmsg) - exploit_record = exploitmsg SetAntagoptions(user) diff --git a/code/modules/clothing/spacesuits/rig/modules/utility.dm b/code/modules/clothing/spacesuits/rig/modules/utility.dm index c670b93791..b4a622075e 100644 --- a/code/modules/clothing/spacesuits/rig/modules/utility.dm +++ b/code/modules/clothing/spacesuits/rig/modules/utility.dm @@ -280,10 +280,10 @@ voice_holder.active = 0 usr << "You disable the speech synthesiser." if("Set Name") - var/raw_choice = input(usr, "Please enter a new name.") as text|null + var/raw_choice = sanitize(input(usr, "Please enter a new name.") as text|null) if(!raw_choice) return 0 - voice_holder.voice = sanitize(raw_choice) + voice_holder.voice = raw_choice usr << "You are now mimicking [voice_holder.voice]." return 1 diff --git a/code/modules/economy/EFTPOS.dm b/code/modules/economy/EFTPOS.dm index c9f1aa1533..c2561423f4 100644 --- a/code/modules/economy/EFTPOS.dm +++ b/code/modules/economy/EFTPOS.dm @@ -167,7 +167,7 @@ if("change_id") var/attempt_code = text2num(input("Re-enter the current EFTPOS access code", "Confirm EFTPOS code")) if(attempt_code == access_code) - eftpos_name = input("Enter a new terminal ID for this device", "Enter new EFTPOS ID") + " EFTPOS scanner" + eftpos_name = sanitize(input("Enter a new terminal ID for this device", "Enter new EFTPOS ID")) + " EFTPOS scanner" print_reference() else usr << "\icon[src]Incorrect code entered." @@ -182,7 +182,7 @@ else usr << "\icon[src]Account not found." if("trans_purpose") - var/choice = input("Enter reason for EFTPOS transaction", "Transaction purpose") + var/choice = sanitize(input("Enter reason for EFTPOS transaction", "Transaction purpose")) if(choice) transaction_purpose = choice if("trans_value") var/try_num = input("Enter amount for EFTPOS transaction", "Transaction amount") as num diff --git a/code/modules/events/event_manager.dm b/code/modules/events/event_manager.dm index daa913a87c..d04eb6db31 100644 --- a/code/modules/events/event_manager.dm +++ b/code/modules/events/event_manager.dm @@ -233,7 +233,7 @@ else if(href_list["back"]) selected_event_container = null else if(href_list["set_name"]) - var/name = input("Enter event name.", "Set Name") as text|null + var/name = sanitize(input("Enter event name.", "Set Name") as text|null) if(name) var/datum/event_meta/EM = locate(href_list["set_name"]) EM.name = name diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 3d1304ab55..45e261792c 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -657,17 +657,11 @@ src << browse(null, "window=flavor_changes") return if("general") - var/msg = input(usr,"Update the general description of your character. This will be shown regardless of clothing, and may include OOC notes and preferences.","Flavor Text",html_decode(flavor_texts[href_list["flavor_change"]])) as message - if(msg != null) - msg = copytext(msg, 1, MAX_MESSAGE_LEN) - msg = html_encode(msg) + var/msg = sanitize(input(usr,"Update the general description of your character. This will be shown regardless of clothing, and may include OOC notes and preferences.","Flavor Text",html_decode(flavor_texts[href_list["flavor_change"]])) as message, extra = 0) flavor_texts[href_list["flavor_change"]] = msg return else - var/msg = input(usr,"Update the flavor text for your [href_list["flavor_change"]].","Flavor Text",html_decode(flavor_texts[href_list["flavor_change"]])) as message - if(msg != null) - msg = copytext(msg, 1, MAX_MESSAGE_LEN) - msg = html_encode(msg) + var/msg = sanitize(input(usr,"Update the flavor text for your [href_list["flavor_change"]].","Flavor Text",html_decode(flavor_texts[href_list["flavor_change"]])) as message, extra = 0) flavor_texts[href_list["flavor_change"]] = msg set_flavor() return diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 2c95605574..4c6f47f36f 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -430,8 +430,8 @@ spawn(0) var/newname - newname = input(src,"You are a robot. Enter a name, or leave blank for the default name.", "Name change","") as text - if (newname != "") + newname = sanitizeSafe(input(src,"You are a robot. Enter a name, or leave blank for the default name.", "Name change","") as text, MAX_NAME_LEN) + if (newname) custom_name = newname updatename() diff --git a/code/modules/mob/living/silicon/robot/robot_items.dm b/code/modules/mob/living/silicon/robot/robot_items.dm index 33748f056e..0d40f0954a 100644 --- a/code/modules/mob/living/silicon/robot/robot_items.dm +++ b/code/modules/mob/living/silicon/robot/robot_items.dm @@ -124,11 +124,11 @@ /obj/item/weapon/pen/robopen/proc/RenamePaper(mob/user as mob,obj/paper as obj) if ( !user || !paper ) return - var/n_name = input(user, "What would you like to label the paper?", "Paper Labelling", null) as text + var/n_name = sanitizeSafe(input(user, "What would you like to label the paper?", "Paper Labelling", null) as text, 32) if ( !user || !paper ) return - n_name = copytext(n_name, 1, 32) + //n_name = copytext(n_name, 1, 32) if(( get_dist(user,paper) <= 1 && user.stat == 0)) paper.name = "paper[(n_name ? text("- '[n_name]'") : null)]" add_fingerprint(user) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 98768bfd41..4379db6c17 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -360,12 +360,9 @@ var/list/slot_equipment_priority = list( \ set src in usr if(usr != src) usr << "No." - var/msg = input(usr,"Set the flavor text in your 'examine' verb. Can also be used for OOC notes about your character.","Flavor Text",html_decode(flavor_text)) as message|null + var/msg = sanitize(input(usr,"Set the flavor text in your 'examine' verb. Can also be used for OOC notes about your character.","Flavor Text",html_decode(flavor_text)) as message|null, extra = 0) if(msg != null) - msg = copytext(msg, 1, MAX_MESSAGE_LEN) - msg = html_encode(msg) - flavor_text = msg /mob/proc/warn_flavor_changed() diff --git a/code/modules/reagents/Chemistry-Machinery.dm b/code/modules/reagents/Chemistry-Machinery.dm index c23927cca9..bef45fbb16 100644 --- a/code/modules/reagents/Chemistry-Machinery.dm +++ b/code/modules/reagents/Chemistry-Machinery.dm @@ -178,7 +178,7 @@ var/amount_per_pill = reagents.total_volume/count if (amount_per_pill > 60) amount_per_pill = 60 - var/name = reject_bad_text(input(usr,"Name:","Name your pill!","[reagents.get_master_reagent_name()] ([amount_per_pill] units)")) + var/name = sanitizeSafe(input(usr,"Name:","Name your pill!","[reagents.get_master_reagent_name()] ([amount_per_pill] units)"), MAX_NAME_LEN) if(reagents.total_volume/count < 1) //Sanity checking. return @@ -197,7 +197,7 @@ else if (href_list["createbottle"]) if(!condi) - var/name = reject_bad_text(input(usr,"Name:","Name your bottle!",reagents.get_master_reagent_name())) + var/name = sanitizeSafe(input(usr,"Name:","Name your bottle!",reagents.get_master_reagent_name()), MAX_NAME_LEN) var/obj/item/weapon/reagent_containers/glass/bottle/P = new/obj/item/weapon/reagent_containers/glass/bottle(src.loc) if(!name) name = reagents.get_master_reagent_name() P.name = "[name] bottle" diff --git a/code/modules/reagents/reagent_containers/food/snacks.dm b/code/modules/reagents/reagent_containers/food/snacks.dm index 502a741c6b..5ebb1dc9a3 100644 --- a/code/modules/reagents/reagent_containers/food/snacks.dm +++ b/code/modules/reagents/reagent_containers/food/snacks.dm @@ -2772,7 +2772,7 @@ if( src.open ) return - var/t = input("Enter what you want to add to the tag:", "Write", null, null) as text + var/t = sanitize(input("Enter what you want to add to the tag:", "Write", null, null) as text, 30) var/obj/item/pizzabox/boxtotagto = src if( boxes.len > 0 ) diff --git a/code/modules/research/xenoarchaeology/chemistry.dm b/code/modules/research/xenoarchaeology/chemistry.dm index f5b718dcf0..eae7b0afc0 100644 --- a/code/modules/research/xenoarchaeology/chemistry.dm +++ b/code/modules/research/xenoarchaeology/chemistry.dm @@ -84,7 +84,7 @@ datum obj/item/weapon/reagent_containers/glass/solution_tray/attackby(obj/item/weapon/W as obj, mob/living/user as mob) if(istype(W, /obj/item/weapon/pen)) - var/new_label = input("What should the new label be?","Label solution tray") + var/new_label = sanitizeSafe(input("What should the new label be?","Label solution tray"), MAX_NAME_LEN) if(new_label) name = "solution tray ([new_label])" user << "\blue You write on the label of the solution tray." diff --git a/code/modules/research/xenoarchaeology/finds/finds_fossils.dm b/code/modules/research/xenoarchaeology/finds/finds_fossils.dm index 57d510015f..80dbf549c0 100644 --- a/code/modules/research/xenoarchaeology/finds/finds_fossils.dm +++ b/code/modules/research/xenoarchaeology/finds/finds_fossils.dm @@ -79,7 +79,7 @@ else ..() else if(istype(W,/obj/item/weapon/pen)) - plaque_contents = input("What would you like to write on the plaque:","Skeleton plaque","") + plaque_contents = sanitize(input("What would you like to write on the plaque:","Skeleton plaque","")) user.visible_message("[user] writes something on the base of [src].","You relabel the plaque on the base of \icon[src] [src].") if(src.contents.Find(/obj/item/weapon/fossil/skull/horned)) src.desc = "A creature made of [src.contents.len-1] assorted bones and a horned skull. The plaque reads \'[plaque_contents]\'." From 31360a344bf40c58a4fec2d29bccc9e23dd296d3 Mon Sep 17 00:00:00 2001 From: volas Date: Wed, 25 Mar 2015 01:13:23 +0300 Subject: [PATCH 5/5] merge fix --- code/modules/paperwork/paper.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/paperwork/paper.dm b/code/modules/paperwork/paper.dm index b1bf92f2cc..758cd78f20 100644 --- a/code/modules/paperwork/paper.dm +++ b/code/modules/paperwork/paper.dm @@ -324,7 +324,7 @@ if(href_list["write"]) var/id = href_list["write"] //var/t = strip_html_simple(input(usr, "What text do you wish to add to " + (id=="end" ? "the end of the paper" : "field "+id) + "?", "[name]", null),8192) as message - var/t = strip_html_simple(input("Enter what you want to write:", "Write", null, null) as message, MAX_PAPER_MESSAGE_LEN) + var/t = sanitize(input("Enter what you want to write:", "Write", null, null) as message, MAX_PAPER_MESSAGE_LEN, extra = 0) var/obj/item/i = usr.get_active_hand() // Check to see if he still got that darn pen, also check if he's using a crayon or pen. var/iscrayon = 0 if(!istype(i, /obj/item/weapon/pen)) @@ -347,7 +347,7 @@ message_admins("PAPER: [usr] ([usr.ckey]) tried to use forbidden word in [src]: [bad].") return */ - t = html_encode(t) + //t = html_encode(t) t = replacetext(t, "\n", "
    ") t = parsepencode(t, i, usr, iscrayon) // Encode everything from pencode to html