mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-10 18:02:57 +00:00
this is better
This commit is contained in:
@@ -53,36 +53,6 @@
|
||||
/proc/sanitize(t,list/repl_chars = null)
|
||||
return html_encode(sanitize_simple(t,repl_chars))
|
||||
|
||||
//Used for preprocessing entered text
|
||||
/proc/sanitize_rp(var/input, var/max_length = MAX_MESSAGE_LEN, var/encode = 1, var/trim = 1, var/extra = 1)
|
||||
if(!input)
|
||||
return
|
||||
|
||||
if(max_length)
|
||||
input = copytext(input,1,max_length)
|
||||
|
||||
if(extra)
|
||||
var/temp_input = replace_characters(input, list("\n"=" ","\t"=" "))//one character is replaced by two
|
||||
if(length_char(input) < (length_char(temp_input) - 12)) //12 is the number of linebreaks allowed per message
|
||||
input = replace_characters(temp_input,list(" "=" "))//replace again, this time the double spaces with single ones
|
||||
|
||||
if(encode)
|
||||
// The below \ escapes have a space inserted to attempt to enable Travis auto-checking of span class usage. Please do not remove the space.
|
||||
//In addition to processing html, html_encode removes byond formatting codes like "\ red", "\ i" and other.
|
||||
//It is important to avoid double-encode text, it can "break" quotes and some other characters.
|
||||
//Also, keep in mind that escaped characters don't work in the interface (window titles, lower left corner of the main window, etc.)
|
||||
input = html_encode(input)
|
||||
else
|
||||
//If not need encode text, simply remove < and >
|
||||
//note: we can also remove here byond formatting codes: 0xFF + next byte
|
||||
input = replace_characters(input, list("<"=" ", ">"=" "))
|
||||
|
||||
if(trim)
|
||||
//Maybe, we need trim text twice? Here and before copytext?
|
||||
input = trim(input)
|
||||
|
||||
return input
|
||||
|
||||
//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(t,limit=MAX_MESSAGE_LEN)
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
to_chat(usr, "<span class='danger'>^^^----- The preceeding message has been DISCARDED for being over the maximum length of [MAX_MESSAGE_LEN]. It has NOT been sent! -----^^^</span>")
|
||||
return
|
||||
|
||||
message = trim(copytext_char(sanitize_rp(message), 1, MAX_MESSAGE_LEN))
|
||||
message = trim(html_encode(message), MAX_MESSAGE_LEN)
|
||||
clear_typing_indicator() // clear it immediately!
|
||||
|
||||
client?.last_activity = world.time
|
||||
|
||||
Reference in New Issue
Block a user