Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitizes burrower tunnel names to alphanumeric only #4911

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions code/__HELPERS/text.dm
Original file line number Diff line number Diff line change
@@ -30,6 +30,11 @@
text = replacetext(text, char, repl_chars[char])
return text

///Helper for only alphanumeric characters plus common punctuation, spaces, underscore and hyphen _ -.
/proc/replace_non_alphanumeric_plus(text)
var/regex/alphanumeric = regex(@{"[^a-z0-9 ,.?!\-_&]"}, "gi")
return alphanumeric.Replace(text, "")

/proc/readd_quotes(text)
var/list/repl_chars = list(""" = "\"", "'" = "'")
for(var/char in repl_chars)
1 change: 1 addition & 0 deletions code/modules/mob/living/carbon/xenomorph/Abilities.dm
Original file line number Diff line number Diff line change
@@ -75,6 +75,7 @@
X.tunnel_delay = 1
addtimer(CALLBACK(src, PROC_REF(cooldown_end)), 4 MINUTES)
var/msg = strip_html(input("Add a description to the tunnel:", "Tunnel Description") as text|null)
msg = replace_non_alphanumeric_plus(msg)
var/description
if(msg)
description = msg
Original file line number Diff line number Diff line change
@@ -189,6 +189,7 @@
return

var/new_name = strip_html(input("Change the description of the tunnel:", "Tunnel Description") as text|null)
new_name = replace_non_alphanumeric_plus(new_name)
if(new_name)
new_name = "[new_name] ([get_area_name(T)])"
log_admin("[key_name(src)] has renamed the tunnel \"[T.tunnel_desc]\" as \"[new_name]\".")