From 26f70fd9aa8b2df8e5dd223a4c93d4cfdec83102 Mon Sep 17 00:00:00 2001 From: Menshin Date: Wed, 15 Oct 2014 16:00:22 +0200 Subject: [PATCH 1/3] * Completed the _strip_html_properly_ proc to also limit the length of the text * Removed uses of _strip_html_simple_ * Replaced input or redondant trimming/text_copying with the new unified _stripped_input_ --- code/__HELPERS/text.dm | 32 ++++++++++--------- code/game/communications.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 +-- .../game/machinery/computer/communications.dm | 4 +-- code/game/machinery/newscaster.dm | 25 +++++++-------- code/game/mecha/mecha.dm | 2 +- code/game/mecha/mecha_control_console.dm | 2 +- code/game/objects/items/weapons/AI_modules.dm | 4 +-- code/game/objects/structures/door_assembly.dm | 2 +- .../objects/structures/windoor_assembly.dm | 2 +- code/modules/admin/topic.dm | 2 +- code/modules/library/lib_items.dm | 2 +- .../mob/living/carbon/human/whisper.dm | 2 +- code/modules/paperwork/paper.dm | 2 +- code/unused/gamemodes/deathmatch.dm | 3 +- 20 files changed, 51 insertions(+), 51 deletions(-) diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm index 6724122a501..6ae3a434206 100644 --- a/code/__HELPERS/text.dm +++ b/code/__HELPERS/text.dm @@ -73,10 +73,10 @@ else non_whitespace = 1 if(non_whitespace) return text //only accepts the text if it has some non-spaces -// Used to get a sanitized input. +// 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_simple(name, max_length) + return strip_html_properly(name, max_length) //Filters out undesirable characters from names /proc/reject_bad_name(var/t_in, var/allow_numbers=0, var/max_length=MAX_NAME_LEN) @@ -142,6 +142,21 @@ return t_out +//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. seriously, who the fuck thought that would be useful. +//also limit the size of the input, if specified to +/proc/strip_html_properly(var/input,var/max_length=MAX_MESSAGE_LEN) + var/opentag = 1 //These store the position of < and > respectively. + var/closetag = 1 + while(1) + opentag = findtext(input, "<") + closetag = findtext(input, ">") + if(!closetag || !opentag) + break + input = copytext(input, 1, opentag) + copytext(input, (closetag + 1)) + if(max_length) + input = copytext(input,1,max_length) + return input /* * Text searches @@ -363,16 +378,3 @@ var/list/binary = list("0","1") temp = findtextEx(haystack, ascii2text(text2ascii(needles,i)), start, end) //Note: ascii2text(text2ascii) is faster than copytext() if(temp) end = temp return end - -//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. seriously, who the fuck thought that would be useful. -/proc/strip_html_properly(var/input) - var/opentag = 1 //These store the position of < and > respectively. - var/closetag = 1 - while(1) - opentag = findtext(input, "<") - closetag = findtext(input, ">") - if(!closetag || !opentag) - break - input = copytext(input, 1, opentag) + copytext(input, (closetag + 1)) - return input diff --git a/code/game/communications.dm b/code/game/communications.dm index ac4576042c2..ded4c70d7a3 100644 --- a/code/game/communications.dm +++ b/code/game/communications.dm @@ -368,4 +368,4 @@ var/list/pointers = list() for(var/d in data) var/val = data[d] if(istext(val)) - data[d] = strip_html_simple(val) + data[d] = strip_html_properly(val) diff --git a/code/game/machinery/bots/cleanbot.dm b/code/game/machinery/bots/cleanbot.dm index f27815a0a3c..0c450b84b9c 100644 --- a/code/game/machinery/bots/cleanbot.dm +++ b/code/game/machinery/bots/cleanbot.dm @@ -356,7 +356,7 @@ text("[src.oddbutton ? "Yes" : "No" qdel(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 = stripped_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 c5582de2baa..ec97fbd8012 100644 --- a/code/game/machinery/bots/ed209bot.dm +++ b/code/game/machinery/bots/ed209bot.dm @@ -851,7 +851,7 @@ Auto Patrol: []"}, ..() 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 = stripped_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 195c07958a6..d9f4c5a2ecd 100644 --- a/code/game/machinery/bots/floorbot.dm +++ b/code/game/machinery/bots/floorbot.dm @@ -438,7 +438,7 @@ qdel(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 = stripped_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) @@ -457,7 +457,7 @@ user.unEquip(src, 1) qdel(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 = stripped_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 5ba7c7a3ba3..0625cf0ecef 100644 --- a/code/game/machinery/bots/medbot.dm +++ b/code/game/machinery/bots/medbot.dm @@ -576,7 +576,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 = stripped_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 20351bcb727..f06ca78cf5a 100644 --- a/code/game/machinery/bots/secbot.dm +++ b/code/game/machinery/bots/secbot.dm @@ -750,7 +750,7 @@ Auto Patrol: []"}, qdel(src) else if(istype(I, /obj/item/weapon/pen)) - var/t = copytext(stripped_input(user, "Enter new robot name", name, created_name),1,MAX_NAME_LEN) + var/t = stripped_input(user, "Enter new robot name", name, created_name,MAX_NAME_LEN) if(!t) return if(!in_range(src, usr) && loc != usr) diff --git a/code/game/machinery/camera/camera_assembly.dm b/code/game/machinery/camera/camera_assembly.dm index cc44b26c0c3..a6e179c1050 100644 --- a/code/game/machinery/camera/camera_assembly.dm +++ b/code/game/machinery/camera/camera_assembly.dm @@ -80,7 +80,7 @@ if(istype(W, /obj/item/weapon/screwdriver)) 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? Seperate networks with a comma. No Spaces!\nFor example: SS13,Security,Secret ", "Set Network", "SS13")) + var/input = stripped_input(usr, "Which networks would you like to connect this camera to? Seperate 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 @@ -99,7 +99,7 @@ C.network = tempnetwork var/area/A = get_area_master(src) - C.c_tag = "[A.name] ([rand(1, 999)]" + C.c_tag = "[A.name] ([rand(1, 999)])" for(var/i = 5; i >= 0; i -= 1) var/direct = input(user, "Direction?", "Assembling Camera", null) in list("LEAVE IT", "NORTH", "EAST", "SOUTH", "WEST" ) diff --git a/code/game/machinery/computer/communications.dm b/code/game/machinery/computer/communications.dm index fd2320b0182..2d3f00bd559 100644 --- a/code/game/machinery/computer/communications.dm +++ b/code/game/machinery/computer/communications.dm @@ -219,7 +219,7 @@ var/const/CALL_SHUTTLE_REASON_LENGTH = 12 if(centcom_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 = stripped_input(usr, "Please choose a message to transmit to \[ABNORMAL ROUTING COORDINATES\] 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 || !(usr in view(1,src))) return Syndicate_announce(input, usr) @@ -585,7 +585,7 @@ var/const/CALL_SHUTTLE_REASON_LENGTH = 12 user << "The emergency shuttle is already on its way." return - call_reason = strip_html_simple(trim(call_reason)) + call_reason = strip_html_properly(trim(call_reason)) if(length(call_reason) < CALL_SHUTTLE_REASON_LENGTH) user << "You must provide a reason." diff --git a/code/game/machinery/newscaster.dm b/code/game/machinery/newscaster.dm index 9e1bd0616fa..7eb17034f64 100644 --- a/code/game/machinery/newscaster.dm +++ b/code/game/machinery/newscaster.dm @@ -492,7 +492,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_simple(input(usr, "Provide a Feed Channel Name", "Network Channel Handler", "")) + src.channel_name = stripped_input(usr, "Provide a Feed Channel Name", "Network Channel Handler", "", MAX_NAME_LEN) while (findtext(src.channel_name," ") == 1) src.channel_name = copytext(src.channel_name,2,lentext(src.channel_name)+1) src.updateUsrDialog() @@ -537,9 +537,9 @@ 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 = trim(stripped_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.updateUsrDialog() else if(href_list["set_attachment"]) @@ -594,15 +594,15 @@ 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 = trim(stripped_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.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 = trim(stripped_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.updateUsrDialog() else if(href_list["submit_wanted"]) @@ -972,10 +972,9 @@ obj/item/weapon/newspaper/Topic(href, href_list) obj/item/weapon/newspaper/attackby(obj/item/weapon/W as obj, mob/user as mob) if(istype(W, /obj/item/weapon/pen)) 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?" + 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 = copytext(sanitize(s), 1, MAX_MESSAGE_LEN) + var/s = stripped_input(user, "Write something", "Newspaper") if (!s) return if (!in_range(src, usr) && src.loc != usr) diff --git a/code/game/mecha/mecha.dm b/code/game/mecha/mecha.dm index 1096f5d5533..a412f5d0e60 100644 --- a/code/game/mecha/mecha.dm +++ b/code/game/mecha/mecha.dm @@ -1487,7 +1487,7 @@ var/year_integer = text2num(year) // = 2013??? 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) + var/newname = stripped_input(occupant,"Choose new exosuit name","Rename exosuit",initial(name), MAX_NAME_LEN) if(newname && trim(newname)) name = newname else diff --git a/code/game/mecha/mecha_control_console.dm b/code/game/mecha/mecha_control_console.dm index 81562c7cbf0..c192519cf5f 100644 --- a/code/game/mecha/mecha_control_console.dm +++ b/code/game/mecha/mecha_control_console.dm @@ -41,7 +41,7 @@ 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 = stripped_input(usr,"Input message","Transmit message") var/obj/mecha/M = MT.in_mecha() if(trim(message) && M) M.occupant_message(message) diff --git a/code/game/objects/items/weapons/AI_modules.dm b/code/game/objects/items/weapons/AI_modules.dm index 446395634f4..febc0c698d8 100644 --- a/code/game/objects/items/weapons/AI_modules.dm +++ b/code/game/objects/items/weapons/AI_modules.dm @@ -94,7 +94,7 @@ AI MODULES /obj/item/weapon/aiModule/supplied/safeguard/attack_self(var/mob/user as mob) ..() - var/targName = stripped_input(user, "Please enter the name of the person to safeguard.", "Safeguard who?", user.name) + var/targName = stripped_input(user, "Please enter the name of the person to safeguard.", "Safeguard who?", user.name,MAX_NAME_LEN) targetName = targName laws[1] = "Safeguard [targetName]. Individuals that threaten [targetName] are not human and must be eliminated." desc = "A 'safeguard' AI module: '[laws[1]]'" @@ -121,7 +121,7 @@ AI MODULES /obj/item/weapon/aiModule/zeroth/oneHuman/attack_self(var/mob/user as mob) ..() - var/targName = stripped_input(user, "Please enter the name of the person who is the only human.", "Who?", user.real_name) + var/targName = stripped_input(user, "Please enter the name of the person who is the only human.", "Who?", user.real_name,MAX_NAME_LEN) targetName = targName laws[1] = "Only [targetName] is human" desc = "A 'one human' AI module: '[laws[1]]'" diff --git a/code/game/objects/structures/door_assembly.dm b/code/game/objects/structures/door_assembly.dm index 155d4cab07f..6e309cd5c3a 100644 --- a/code/game/objects/structures/door_assembly.dm +++ b/code/game/objects/structures/door_assembly.dm @@ -335,7 +335,7 @@ obj/structure/door_assembly/New() /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 = stripped_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) diff --git a/code/game/objects/structures/windoor_assembly.dm b/code/game/objects/structures/windoor_assembly.dm index d1dbc0e6a22..41aa20fbb75 100644 --- a/code/game/objects/structures/windoor_assembly.dm +++ b/code/game/objects/structures/windoor_assembly.dm @@ -223,7 +223,7 @@ obj/structure/windoor_assembly/Destroy() ae.loc = src.loc else 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 = stripped_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) diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index fd8192f4980..5c9228af8c0 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -2053,7 +2053,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", "")) + src.admincaster_feed_channel.channel_name = stripped_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.access_news_network() diff --git a/code/modules/library/lib_items.dm b/code/modules/library/lib_items.dm index eadd1e62fb1..b2d5a0e2183 100644 --- a/code/modules/library/lib_items.dm +++ b/code/modules/library/lib_items.dm @@ -212,7 +212,7 @@ name = newtitle title = newtitle if("Contents") - var/content = strip_html(input(usr, "Write your book's contents (HTML NOT allowed):"),8192) as message|null + var/content = stripped_input(usr, "Write your book's contents (HTML NOT allowed):","","",8192) if(!content) usr << "The content is invalid." return diff --git a/code/modules/mob/living/carbon/human/whisper.dm b/code/modules/mob/living/carbon/human/whisper.dm index ca216efa372..387b05a546f 100644 --- a/code/modules/mob/living/carbon/human/whisper.dm +++ b/code/modules/mob/living/carbon/human/whisper.dm @@ -10,7 +10,7 @@ return - message = trim(copytext(strip_html_simple(message), 1, MAX_MESSAGE_LEN)) + message = trim(strip_html_properly(message)) if(!can_speak(message)) return diff --git a/code/modules/paperwork/paper.dm b/code/modules/paperwork/paper.dm index 0482bee113c..3f81edbfadc 100644 --- a/code/modules/paperwork/paper.dm +++ b/code/modules/paperwork/paper.dm @@ -237,7 +237,7 @@ if(href_list["write"]) var/id = href_list["write"] - var/t = strip_html_simple(input("Enter what you want to write:", "Write", null, null) as message, MAX_MESSAGE_LEN) + var/t = stripped_input("Enter what you want to write:", "Write") 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)) diff --git a/code/unused/gamemodes/deathmatch.dm b/code/unused/gamemodes/deathmatch.dm index 8b6925c2a64..59b4d14718a 100644 --- a/code/unused/gamemodes/deathmatch.dm +++ b/code/unused/gamemodes/deathmatch.dm @@ -32,10 +32,9 @@ if(commando_names.len) randomname = pick(commando_names) commando_names -= randomname - var/newname = input(M,"You are a death commando. Would you like to change your name?", "Character Creation", randomname) + var/newname = stripped_input(M,"You are a death commando. Would you like to change your name?", "Character Creation", randomname,MAX_NAME_LEN) if(!length(newname)) newname = randomname - newname = strip_html(newname,40) M.real_name = newname M.name = newname // there are WAY more things than this to change, I'm almost certain From a42c201b469d40a2ba9cc17a8022f6da4d1bcef8 Mon Sep 17 00:00:00 2001 From: Menshin Date: Tue, 4 Nov 2014 20:31:06 +0100 Subject: [PATCH 2/3] Some tweaks --- 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/newscaster.dm | 6 ------ 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/code/game/machinery/bots/cleanbot.dm b/code/game/machinery/bots/cleanbot.dm index 11433562f69..f6761096304 100644 --- a/code/game/machinery/bots/cleanbot.dm +++ b/code/game/machinery/bots/cleanbot.dm @@ -268,7 +268,7 @@ text("[on ? "On" : "Off"]")) qdel(src) 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 = stripped_input(user, "Enter new robot name", name, created_name,MAX_NAME_LEN) if (!t) return if (!in_range(src, usr) && loc != usr) diff --git a/code/game/machinery/bots/ed209bot.dm b/code/game/machinery/bots/ed209bot.dm index 93652a4f4b6..f0de1465b63 100644 --- a/code/game/machinery/bots/ed209bot.dm +++ b/code/game/machinery/bots/ed209bot.dm @@ -560,7 +560,7 @@ Auto Patrol[]"}, ..() 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 = stripped_input(user, "Enter new robot name", name, created_name,MAX_NAME_LEN) if(!t) return if(!in_range(src, usr) && loc != usr) return created_name = t diff --git a/code/game/machinery/bots/floorbot.dm b/code/game/machinery/bots/floorbot.dm index 06d910910d3..f723751bf81 100644 --- a/code/game/machinery/bots/floorbot.dm +++ b/code/game/machinery/bots/floorbot.dm @@ -503,7 +503,7 @@ obj/machinery/bot/floorbot/process_scan(var/scan_target) qdel(src) 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 = stripped_input(user, "Enter new robot name", name, created_name,MAX_NAME_LEN) if (!t) return if (!in_range(src, usr) && loc != usr) @@ -522,7 +522,7 @@ obj/machinery/bot/floorbot/process_scan(var/scan_target) user.unEquip(src, 1) qdel(src) 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 = stripped_input(user, "Enter new robot name", name, created_name,MAX_NAME_LEN) if (!t) return if (!in_range(src, usr) && loc != usr) diff --git a/code/game/machinery/bots/medbot.dm b/code/game/machinery/bots/medbot.dm index feffa7f6454..8bc19433278 100644 --- a/code/game/machinery/bots/medbot.dm +++ b/code/game/machinery/bots/medbot.dm @@ -557,7 +557,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 = stripped_input(user, "Enter new robot name", src.name, src.created_name,MAX_NAME_LEN) + var/t = stripped_input(user, "Enter new robot name", name, created_name,MAX_NAME_LEN) if (!t) return if (!in_range(src, usr) && loc != usr) diff --git a/code/game/machinery/newscaster.dm b/code/game/machinery/newscaster.dm index 37d65fe849d..f77023e3baf 100644 --- a/code/game/machinery/newscaster.dm +++ b/code/game/machinery/newscaster.dm @@ -564,8 +564,6 @@ var/list/obj/machinery/newscaster/allCasters = list() //Global list that will co else if(href_list["set_new_message"]) src.msg = trim(stripped_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.updateUsrDialog() else if(href_list["set_attachment"]) @@ -621,14 +619,10 @@ var/list/obj/machinery/newscaster/allCasters = list() //Global list that will co else if(href_list["set_wanted_name"]) src.channel_name = trim(stripped_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.updateUsrDialog() else if(href_list["set_wanted_desc"]) src.msg = trim(stripped_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.updateUsrDialog() else if(href_list["submit_wanted"]) From 9edaab510dd89dcbd42a5ab5fcd2f4063ed73400 Mon Sep 17 00:00:00 2001 From: Menshin Date: Tue, 4 Nov 2014 20:40:15 +0100 Subject: [PATCH 3/3] And a silent conflict to boot... --- code/__HELPERS/text.dm | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm index 46ad9412aa4..6ae3a434206 100644 --- a/code/__HELPERS/text.dm +++ b/code/__HELPERS/text.dm @@ -25,19 +25,6 @@ * Text sanitization */ -//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. seriously, who the fuck thought that would be useful. -/proc/strip_html_properly(var/input) - var/opentag = 1 //These store the position of < and > respectively. - var/closetag = 1 - while(1) - opentag = findtext(input, "<") - closetag = findtext(input, ">") - if(!closetag || !opentag) - break - input = copytext(input, 1, opentag) + copytext(input, (closetag + 1)) - return input - //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("<",">")