Skip to content

Commit

Permalink
Sanitizes burrower tunnel names to alphanumeric only (#4911)
Browse files Browse the repository at this point in the history
# About the pull request

Someone made a tunnel with the characters `'🐝・゚ ・゚·:。・゚゚・` and the
tunnel was broken and not usable. This PR restricts them to alphanumeric
characters only.

# Explain why it's good for the game
# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl:
fix: Restricts burrower tunnels to alphanumeric characters as some other
characters break the tunnel.
code; Adds new proc to replace non alphanumeric or space characters.
/:cl:
  • Loading branch information
Birdtalon authored Dec 1, 2023
1 parent 893d01b commit 8e7a704
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions code/__HELPERS/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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("&#34;" = "\"", "&#39;" = "'")
for(var/char in repl_chars)
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/carbon/xenomorph/Abilities.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,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]\".")
Expand Down

0 comments on commit 8e7a704

Please sign in to comment.