From 9fedfc7c6270b3aef93a9d241e7c885e3dd07b0d Mon Sep 17 00:00:00 2001 From: Markolie Date: Fri, 20 Feb 2015 22:17:13 +0100 Subject: [PATCH] Switch copytext and sanitize proc --- code/__HELPERS/mobs.dm | 2 ++ code/__HELPERS/text.dm | 7 ++--- code/datums/datumvars.dm | 2 +- code/datums/mind.dm | 4 +-- code/game/gamemodes/blob/overmind.dm | 2 +- code/game/gamemodes/events/ninja_equipment.dm | 2 +- code/game/gamemodes/events/space_ninja.dm | 2 +- code/game/gamemodes/nuclear/nuclear.dm | 2 +- code/game/gamemodes/objective.dm | 2 +- code/game/gamemodes/wizard/artefact.dm | 2 +- code/game/gamemodes/wizard/wizard.dm | 2 +- code/game/jobs/job/support_chaplain.dm | 4 +-- code/game/machinery/atmoalter/canister.dm | 2 +- code/game/machinery/bots/farmbot.dm | 2 +- code/game/machinery/bots/mulebot.dm | 2 +- code/game/machinery/computer/card.dm | 2 +- code/game/machinery/computer/message.dm | 2 +- code/game/machinery/computer/prisoner.dm | 2 +- 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 | 4 +-- code/game/objects/items/devices/flash.dm | 5 ++-- code/game/objects/items/devices/megaphone.dm | 2 +- code/game/objects/items/devices/paicard.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/supplyshuttle.dm | 4 +-- code/game/verbs/ooc.dm | 4 +-- code/modules/admin/topic.dm | 2 +- code/modules/admin/verbs/adminsay.dm | 4 +-- code/modules/admin/verbs/deadsay.dm | 2 +- code/modules/admin/verbs/honksquad.dm | 2 +- code/modules/admin/verbs/pray.dm | 8 +++--- code/modules/admin/verbs/striketeam.dm | 2 +- .../admin/verbs/striketeam_syndicate.dm | 2 +- code/modules/computer3/computers/card.dm | 2 +- code/modules/computer3/computers/medical.dm | 28 +++++++++---------- code/modules/computer3/computers/message.dm | 2 +- code/modules/computer3/computers/prisoner.dm | 2 +- code/modules/computer3/computers/security.dm | 18 ++++++------ code/modules/library/lib_machines.dm | 6 ++-- code/modules/mob/emote.dm | 4 +-- code/modules/mob/living/carbon/human/emote.dm | 6 ++-- code/modules/mob/living/carbon/human/human.dm | 4 +-- .../mob/living/carbon/metroid/metroid.dm | 4 +-- .../modules/mob/living/silicon/pai/recruit.dm | 16 +++++------ .../modules/mob/living/silicon/robot/robot.dm | 2 +- code/modules/mob/living/silicon/silicon.dm | 4 +-- .../modules/mob/living/simple_animal/borer.dm | 2 +- code/modules/mob/mob_helpers.dm | 4 +-- code/modules/paperwork/faxmachine.dm | 2 +- code/modules/paperwork/folders.dm | 2 +- code/modules/paperwork/paper.dm | 4 +-- code/modules/paperwork/paper_bundle.dm | 2 +- code/modules/paperwork/photography.dm | 2 +- .../reagent_containers/food/snacks.dm | 2 +- code/modules/recycling/sortingmachinery.dm | 4 +-- code/modules/telesci/gps.dm | 2 +- 62 files changed, 117 insertions(+), 117 deletions(-) diff --git a/code/__HELPERS/mobs.dm b/code/__HELPERS/mobs.dm index 320e2ecd8d7..81ed859a7e5 100644 --- a/code/__HELPERS/mobs.dm +++ b/code/__HELPERS/mobs.dm @@ -132,6 +132,8 @@ Proc for attack log creation, because really why not proc/add_logs(mob/target, mob/user, what_done, var/object=null, var/addition=null) var/list/ignore=list("shaked","CPRed","grabbed","punched") + if(!user) + return if(ismob(user)) user.attack_log += text("\[[time_stamp()]\] Has [what_done] [target.name][ismob(target) ? "([target.ckey])" : ""][object ? " with [object]" : " "][addition]") if(ismob(target)) diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm index 108246c5ad5..c6cd633398b 100644 --- a/code/__HELPERS/text.dm +++ b/code/__HELPERS/text.dm @@ -34,12 +34,9 @@ return t //Removes a few problematic characters -/proc/sanitize_simple(var/t,var/list/repl_chars = list("\n"="#","\t"="#","�"="�")) +/proc/sanitize_simple(var/t,var/list/repl_chars = list("\n"="#","\t"="#")) for(var/char in repl_chars) - var/index = findtext(t, char) - while(index) - t = copytext(t, 1, index) + repl_chars[char] + copytext(t, index+1) - index = findtext(t, char) + replacetext(t, char, repl_chars[char]) return t /proc/readd_quotes(var/t) diff --git a/code/datums/datumvars.dm b/code/datums/datumvars.dm index d202f29d8f9..a7db9300c73 100644 --- a/code/datums/datumvars.dm +++ b/code/datums/datumvars.dm @@ -441,7 +441,7 @@ client usr << "This can only be used on instances of type /mob" return - var/new_name = copytext(sanitize(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(copytext(input(usr,"What would you like to name this mob?","Input a name",M.real_name) as text|null,1,MAX_NAME_LEN)) if( !new_name || !M ) return message_admins("Admin [key_name_admin(usr)] renamed [key_name_admin(M)] to [new_name].") diff --git a/code/datums/mind.dm b/code/datums/mind.dm index caea97b2f7d..527ea37bb14 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -446,7 +446,7 @@ datum/mind assigned_role = new_role else if (href_list["memory_edit"]) - var/new_memo = copytext(sanitize(input("Write new memory", "Memory", memory) as null|message),1,MAX_MESSAGE_LEN) + var/new_memo = sanitize(copytext(input("Write new memory", "Memory", memory) as null|message,1,MAX_MESSAGE_LEN)) if (isnull(new_memo)) return memory = new_memo @@ -585,7 +585,7 @@ datum/mind new_objective.find_target() if ("custom") - var/expl = copytext(sanitize(input("Custom objective:", "Objective", objective ? objective.explanation_text : "") as text|null),1,MAX_MESSAGE_LEN) + var/expl = sanitize(copytext(input("Custom objective:", "Objective", objective ? objective.explanation_text : "") as text|null,1,MAX_MESSAGE_LEN)) if (!expl) return new_objective = new /datum/objective new_objective.owner = src diff --git a/code/game/gamemodes/blob/overmind.dm b/code/game/gamemodes/blob/overmind.dm index 8316c570f9a..5f3b1bf796e 100644 --- a/code/game/gamemodes/blob/overmind.dm +++ b/code/game/gamemodes/blob/overmind.dm @@ -65,7 +65,7 @@ /mob/camera/blob/proc/blob_talk(message) log_say("[key_name(src)] : [message]") - message = trim(copytext(sanitize(message), 1, MAX_MESSAGE_LEN)) + message = trim(sanitize(copytext(message, 1, MAX_MESSAGE_LEN))) if (!message) return diff --git a/code/game/gamemodes/events/ninja_equipment.dm b/code/game/gamemodes/events/ninja_equipment.dm index 95b3243ae84..a02fc5042e7 100644 --- a/code/game/gamemodes/events/ninja_equipment.dm +++ b/code/game/gamemodes/events/ninja_equipment.dm @@ -564,7 +564,7 @@ ________________________________________________________________________________ if("Message") var/obj/item/device/pda/P = locate(href_list["target"]) var/t = input(U, "Please enter untraceable message.") as text - t = copytext(sanitize(t), 1, MAX_MESSAGE_LEN) + t = sanitize(copytext(t, 1, MAX_MESSAGE_LEN)) if(!t||U.stat||U.wear_suit!=src||!s_initialized)//Wow, another one of these. Man... display_to << browse(null, "window=spideros") return diff --git a/code/game/gamemodes/events/space_ninja.dm b/code/game/gamemodes/events/space_ninja.dm index 9a17a188ec0..1792e573a5b 100644 --- a/code/game/gamemodes/events/space_ninja.dm +++ b/code/game/gamemodes/events/space_ninja.dm @@ -480,7 +480,7 @@ As such, it's hard-coded for now. No reason for it not to be, really. var/mission if(alert("Would you the Ninja to have a random or preset mission?",,"Random","Preset")=="Preset") while(!mission) - mission = copytext(sanitize(input(src, "Please specify which mission the space ninja shall undertake.", "Specify Mission", "")),1,MAX_MESSAGE_LEN) + mission = sanitize(copytext(input(src, "Please specify which mission the space ninja shall undertake.", "Specify Mission", ""),1,MAX_MESSAGE_LEN)) if(!mission) if(alert("Error, no mission set. Do you want to exit the setup process?",,"Yes","No")=="Yes") return diff --git a/code/game/gamemodes/nuclear/nuclear.dm b/code/game/gamemodes/nuclear/nuclear.dm index 6deb483f0fa..de5d25bd9d1 100644 --- a/code/game/gamemodes/nuclear/nuclear.dm +++ b/code/game/gamemodes/nuclear/nuclear.dm @@ -441,7 +441,7 @@ proc/issyndicate(mob/living/M as mob) /proc/nukelastname(var/mob/M as mob) //--All praise goes to NEO|Phyte, all blame goes to DH, and it was Cindi-Kate's idea. Also praise Urist for copypasta ho. var/randomname = pick(last_names) - var/newname = copytext(sanitize(input(M,"You are the nuke operative [pick("Czar", "Boss", "Commander", "Chief", "Kingpin", "Director", "Overlord")]. Please choose a last name for your family.", "Name change",randomname)),1,MAX_NAME_LEN) + var/newname = sanitize(copytext(input(M,"You are the nuke operative [pick("Czar", "Boss", "Commander", "Chief", "Kingpin", "Director", "Overlord")]. Please choose a last name for your family.", "Name change",randomname),1,MAX_NAME_LEN)) if (!newname) newname = randomname diff --git a/code/game/gamemodes/objective.dm b/code/game/gamemodes/objective.dm index af9cfac6fbe..2a7d8b14368 100644 --- a/code/game/gamemodes/objective.dm +++ b/code/game/gamemodes/objective.dm @@ -619,7 +619,7 @@ datum/objective/steal var/tmp_obj = new O.typepath var/custom_name = tmp_obj:name del(tmp_obj) - O.name = copytext(sanitize(input("Enter target name:", "Objective target", custom_name) as text|null),1,MAX_NAME_LEN) + O.name = sanitize(copytext(input("Enter target name:", "Objective target", custom_name) as text|null,1,MAX_NAME_LEN)) if (!O.name) return steal_target = O explanation_text = "Steal [O.name]." diff --git a/code/game/gamemodes/wizard/artefact.dm b/code/game/gamemodes/wizard/artefact.dm index b0471908eaf..4bda30ebe02 100644 --- a/code/game/gamemodes/wizard/artefact.dm +++ b/code/game/gamemodes/wizard/artefact.dm @@ -87,7 +87,7 @@ var/wizard_name_first = pick(wizard_first) var/wizard_name_second = pick(wizard_second) var/randomname = "[wizard_name_first] [wizard_name_second]" - var/newname = copytext(sanitize(input(M, "You are the wizard's apprentice. Would you like to change your name to something else?", "Name change", randomname) as null|text),1,MAX_NAME_LEN) + var/newname = sanitize(copytext(input(M, "You are the wizard's apprentice. Would you like to change your name to something else?", "Name change", randomname) as null|text,1,MAX_NAME_LEN)) if (!newname) newname = randomname diff --git a/code/game/gamemodes/wizard/wizard.dm b/code/game/gamemodes/wizard/wizard.dm index cd59d23d0b5..78be858d796 100644 --- a/code/game/gamemodes/wizard/wizard.dm +++ b/code/game/gamemodes/wizard/wizard.dm @@ -116,7 +116,7 @@ var/wizard_name_second = pick(wizard_second) var/randomname = "[wizard_name_first] [wizard_name_second]" spawn(0) - var/newname = copytext(sanitize(input(wizard_mob, "You are the Space Wizard. Would you like to change your name to something else?", "Name change", randomname) as null|text),1,MAX_NAME_LEN) + var/newname = sanitize(copytext(input(wizard_mob, "You are the Space Wizard. Would you like to change your name to something else?", "Name change", randomname) as null|text,1,MAX_NAME_LEN)) if (!newname) newname = randomname diff --git a/code/game/jobs/job/support_chaplain.dm b/code/game/jobs/job/support_chaplain.dm index f02f111c0fb..d56f478fc42 100644 --- a/code/game/jobs/job/support_chaplain.dm +++ b/code/game/jobs/job/support_chaplain.dm @@ -24,7 +24,7 @@ H.equip_or_collect(new /obj/item/weapon/storage/box/survival(H.back), slot_in_backpack) spawn(0) var/religion_name = "Christianity" - var/new_religion = copytext(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)),1,MAX_NAME_LEN) + 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)) if (!new_religion) new_religion = religion_name @@ -59,7 +59,7 @@ spawn(1) var/deity_name = "Space Jesus" - var/new_deity = copytext(sanitize(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(copytext(input(H, "Would you like to change your deity? Default is Space Jesus.", "Name change", deity_name),1,MAX_NAME_LEN)) if ((length(new_deity) == 0) || (new_deity == "Space Jesus") ) new_deity = deity_name diff --git a/code/game/machinery/atmoalter/canister.dm b/code/game/machinery/atmoalter/canister.dm index 17492a83ba4..8ae1166ff29 100644 --- a/code/game/machinery/atmoalter/canister.dm +++ b/code/game/machinery/atmoalter/canister.dm @@ -470,7 +470,7 @@ update_flag if (href_list["rename"]) if (can_label) - var/T = copytext(sanitize(input("Choose canister label", "Name", name) as text|null),1,MAX_NAME_LEN) + var/T = sanitize(copytext(input("Choose canister label", "Name", name) as text|null,1,MAX_NAME_LEN)) if (can_label) //Exploit prevention if (T) name = T diff --git a/code/game/machinery/bots/farmbot.dm b/code/game/machinery/bots/farmbot.dm index 3c13b04ff96..d5eff718549 100644 --- a/code/game/machinery/bots/farmbot.dm +++ b/code/game/machinery/bots/farmbot.dm @@ -585,7 +585,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 = copytext(sanitize(t), 1, MAX_NAME_LEN) + t = sanitize(copytext(t), 1, 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 4e15b07fe01..bbab6f7d9e7 100644 --- a/code/game/machinery/bots/mulebot.dm +++ b/code/game/machinery/bots/mulebot.dm @@ -324,7 +324,7 @@ var/global/mulebot_count = 0 if("setid") refresh=0 - var/new_id = copytext(sanitize(input("Enter new bot ID", "Mulebot [suffix ? "([suffix])" : ""]", suffix) as text|null),1,MAX_NAME_LEN) + var/new_id = sanitize(copytext(input("Enter new bot ID", "Mulebot [suffix ? "([suffix])" : ""]", suffix) as text|null,1,MAX_NAME_LEN)) refresh=1 if(new_id) suffix = new_id diff --git a/code/game/machinery/computer/card.dm b/code/game/machinery/computer/card.dm index 6298f0d7d89..87552942026 100644 --- a/code/game/machinery/computer/card.dm +++ b/code/game/machinery/computer/card.dm @@ -198,7 +198,7 @@ if (is_authenticated() && modify) var/t1 = href_list["assign_target"] if(t1 == "Custom") - var/temp_t = copytext(sanitize(input("Enter a custom job assignment.","Assignment")),1,MAX_MESSAGE_LEN) + var/temp_t = sanitize(copytext(input("Enter a custom job assignment.","Assignment"),1,MAX_MESSAGE_LEN)) //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/message.dm b/code/game/machinery/computer/message.dm index 916b99e05c9..879e6b8f150 100644 --- a/code/game/machinery/computer/message.dm +++ b/code/game/machinery/computer/message.dm @@ -422,7 +422,7 @@ //Enter message if("Message") custommessage = input(usr, "Please enter your message.") as text|null - custommessage = copytext(sanitize(custommessage), 1, MAX_MESSAGE_LEN) + custommessage = sanitize(copytext(custommessage, 1, MAX_MESSAGE_LEN)) //Send message if("Send") diff --git a/code/game/machinery/computer/prisoner.dm b/code/game/machinery/computer/prisoner.dm index 8340838f6e2..7b4b37665b0 100644 --- a/code/game/machinery/computer/prisoner.dm +++ b/code/game/machinery/computer/prisoner.dm @@ -129,7 +129,7 @@ usr << "Unauthorized Access." else if(href_list["warn"]) - var/warning = copytext(sanitize(input(usr,"Message:","Enter your message here!","")),1,MAX_MESSAGE_LEN) + var/warning = sanitize(copytext(input(usr,"Message:","Enter your message here!",""),1,MAX_MESSAGE_LEN)) if(!warning) return var/obj/item/weapon/implant/I = locate(href_list["warn"]) if((I)&&(I.imp_in)) diff --git a/code/game/machinery/magnet.dm b/code/game/machinery/magnet.dm index a2dd432d991..8569ede3fd7 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 = copytext(sanitize(input(usr, "Please define a new path!",,path) as text|null),1,MAX_MESSAGE_LEN) + var/newpath = sanitize(copytext(input(usr, "Please define a new path!",,path) as text|null,1,MAX_MESSAGE_LEN)) if(newpath && newpath != "") moving = 0 // stop moving path = newpath diff --git a/code/game/machinery/navbeacon.dm b/code/game/machinery/navbeacon.dm index 59bf0f2ea17..414c6c365b1 100644 --- a/code/game/machinery/navbeacon.dm +++ b/code/game/machinery/navbeacon.dm @@ -193,7 +193,7 @@ Transponder Codes: