diff --git a/code/game/supplyshuttle.dm b/code/game/supplyshuttle.dm index bfc3c579f36c..8214ee76d091 100644 --- a/code/game/supplyshuttle.dm +++ b/code/game/supplyshuttle.dm @@ -667,9 +667,12 @@ GLOBAL_DATUM_INIT(supply_controller, /datum/controller/supply, new()) var/list/packages -/obj/item/paper/manifest/read_paper(mob/user) +/obj/item/paper/manifest/read_paper(mob/user, scramble = FALSE) + var/paper_info = info + if(scramble) + paper_info = stars_decode_html(info) // Tossing ref in widow id as this allows us to read multiple manifests at same time - show_browser(user, "[info][stamps]", null, "manifest\ref[src]", "size=550x650") + show_browser(user, "[paper_info][stamps]", null, "manifest\ref[src]", "size=550x650") onclose(user, "manifest\ref[src]") /obj/item/paper/manifest/proc/generate_contents() diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 693eebabcb99..4f9244126c36 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -131,6 +131,72 @@ GLOBAL_LIST_INIT(limb_types_by_name, list( index++ return output_message +/** + * Summary: proc that parses an html input string and scrambles the non-html string contents. + * + * Arguments: + * * message - an html string value to be parsed and modified. + * + * Return: + * returns the parsed and modified html output with the text content being partially scrambled with asteriks + */ +/proc/stars_decode_html(message) + if(!length(message)) + return + + // boolean value to know if the current indexed element needs to be scrambled. + var/parsing_message = FALSE + + // boolean values to know if we are currently inside a double or single quotation. + var/in_single_quote = FALSE + var/in_double_quote = FALSE + + // string of what tag we're currently in + var/current_tag = "" + var/escaped_tag = FALSE + + // string that will be scrambled + var/current_string_to_scramble = "" + + // output string after parse + var/output_message = "" + for(var/character_index in 1 to length(message)) + var/current_char = message[character_index] + + // Apparent edge case safety, we only want to check the < and > on the edges of the tag. + if(!parsing_message) + if(current_char == "'") + in_single_quote = !in_single_quote + if(current_char == "\"") + in_double_quote = !in_double_quote + if(in_single_quote || in_double_quote) + output_message += current_char + continue + + if(current_char == ">") + parsing_message = TRUE + output_message += current_char + current_tag += current_char + if(findtext(current_tag, "") == 1 || findtext(current_tag, "[stars(info)][stamps]", name, name, "size=650x700") - onclose(user, name) + read_paper(user,scramble = TRUE) else read_paper(user) else . += SPAN_NOTICE("It is too far away.") -/obj/item/paper/proc/read_paper(mob/user) +/obj/item/paper/proc/read_paper(mob/user, scramble = FALSE) var/datum/asset/asset_datum = get_asset_datum(/datum/asset/simple/paper) asset_datum.send(user) if(photo_list) for(var/photo in photo_list) user << browse_rsc(photo_list[photo], photo) - show_browser(user, "[info][stamps]", name, name, "size=650x700") + var/paper_info = info + if(scramble) + paper_info = stars_decode_html(info) + show_browser(user, "[paper_info][stamps]", name, name, "size=650x700") onclose(user, name) /obj/item/paper/verb/rename()