From 11b2cec57d21e70eff82f49c0eed3f111274af02 Mon Sep 17 00:00:00 2001 From: AffectedArc07 Date: Sat, 9 Feb 2019 09:25:50 +0000 Subject: [PATCH] Allows lesser sanitization --- code/__HELPERS/text.dm | 6 ++++++ code/modules/ext_scripts/irc.dm | 16 ++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm index c7380d9f402..9dd3c870d51 100644 --- a/code/__HELPERS/text.dm +++ b/code/__HELPERS/text.dm @@ -59,10 +59,16 @@ /proc/sanitize(var/t,var/list/repl_chars = null) return html_encode(sanitize_simple(t,repl_chars)) +// Gut ANYTHING that isnt alphanumeric, or brackets /proc/paranoid_sanitize(t) var/regex/alphanum_only = regex("\[^a-zA-Z0-9# ,.?!:;()]", "g") return alphanum_only.Replace(t, "#") +// Less agressive, to allow discord features, such as <>, / and @ +/proc/not_as_paranoid_sanitize(t) + var/regex/alphanum_slashes_only = regex("\[^a-zA-Z0-9# ,.?!:;()/<>@]", "g") + return alphanum_slashes_only.Replace(t, "#") + //Runs sanitize and strip_html_simple //I believe strip_html_simple() is required to run first to prevent '<' from displaying as '<' after sanitize() calls byond's html_encode() /proc/strip_html(var/t,var/limit=MAX_MESSAGE_LEN) diff --git a/code/modules/ext_scripts/irc.dm b/code/modules/ext_scripts/irc.dm index 11b799aa203..a8c483c1130 100644 --- a/code/modules/ext_scripts/irc.dm +++ b/code/modules/ext_scripts/irc.dm @@ -1,14 +1,18 @@ -/proc/send2irc(var/channel, var/msg) +/proc/send2irc(var/channel, var/msg, var/lesser_sanitize=0) if(config.use_irc_bot && config.irc_bot_host.len) for(var/IP in config.irc_bot_host) spawn(0) - // I have no means of trusting you, cmd - ext_python("ircbot_message.py", "[config.comms_password] [IP] [channel] [paranoid_sanitize(msg)]") + if(lesser_sanitize == 7355608) // Super random number because this could be bad if done accidentally + // Runs sanitization but allows <> and // (Needed for discord) + ext_python("ircbot_message.py", "[config.comms_password] [IP] [channel] [not_as_paranoid_sanitize(msg)]") + else + // I have no means of trusting you, cmd + ext_python("ircbot_message.py", "[config.comms_password] [IP] [channel] [paranoid_sanitize(msg)]") return -/proc/send2mainirc(var/msg) +/proc/send2mainirc(var/msg, var/lesser_sanitize=0) if(config.main_irc) - send2irc(config.main_irc, msg) + send2irc(config.main_irc, msg, lesser_sanitize) return /proc/send2adminirc(var/msg) @@ -25,7 +29,7 @@ else while(pull_notify.NextRow()) people_to_ping += "<@" + pull_notify.item[1] + "> " - send2mainirc("Server starting up on [station_name()]. Connect to: "+people_to_ping) + send2mainirc("Server starting up on [station_name()]. Connect to: "+people_to_ping, 7355608) // Set notify to 0 so people arent pinged round after round var/DBQuery/reset_notify = dbcon.NewQuery("UPDATE [format_table_name("discord")] SET notify = 0 WHERE notify = 1") if(!reset_notify.Execute())