Merge pull request #3654 from Tastyfish/pre-pre-510

Fixes sanitize_simple() to work
This commit is contained in:
Fox McCloud
2016-02-24 06:48:27 -05:00
+10 -11
View File
@@ -19,8 +19,8 @@
return copytext(sqltext, 2, lentext(sqltext));//Quote() adds quotes around input, we already do that
/proc/format_table_name(table as text)
return sqlfdbktableprefix + table
return sqlfdbktableprefix + table
/*
* Text sanitization
*/
@@ -39,9 +39,9 @@
//Removes a few problematic characters
/proc/sanitize_simple(var/t,var/list/repl_chars = list("\n"="#","\t"="#"))
for(var/char in repl_chars)
replacetext(t, char, repl_chars[char])
t = replacetext(t, char, repl_chars[char])
return t
/proc/readd_quotes(var/t)
var/list/repl_chars = list(""" = "\"")
for(var/char in repl_chars)
@@ -210,12 +210,11 @@ proc/checkhtml(var/t)
/proc/replacetextEx(text, find, replacement)
return list2text(text2listEx(text, find), replacement)
#endif
/proc/replace_characters(var/t,var/list/repl_chars)
for(var/char in repl_chars)
t = replacetext(t, char, repl_chars[char])
return t
return t
//Adds 'u' number of zeros ahead of the text 't'
/proc/add_zero(t, u)
while (length(t) < u)
@@ -320,7 +319,7 @@ proc/checkhtml(var/t)
for(var/i = length(text); i > 0; i--)
new_text += copytext(text, i, i+1)
return new_text
//This proc strips html properly, but it's not lazy like the other procs.
//This means that it doesn't just remove < and > and call it a day.
//Also limit the size of the input, if specified.
@@ -350,7 +349,7 @@ proc/checkhtml(var/t)
/proc/trim_strip_html_properly(var/input, var/max_length = MAX_MESSAGE_LEN)
return trim(strip_html_properly(input, max_length))
//Used in preferences' SetFlavorText and human's set_flavor verb
//Previews a string of len or less length
/proc/TextPreview(var/string,var/len=40)
@@ -365,10 +364,10 @@ proc/checkhtml(var/t)
//alternative copytext() for encoded text, doesn't break html entities (&#34; and other)
/proc/copytext_preserve_html(var/text, var/first, var/last)
return html_encode(copytext(html_decode(text), first, last))
//Run sanitize(), but remove <, >, " first to prevent displaying them as &gt; &lt; &34; in some places, after html_encode().
//Best used for sanitize object names, window titles.
//If you have a problem with sanitize() in chat, when quotes and >, < are displayed as html entites -
//this is a problem of double-encode(when & becomes &amp;), use sanitize() with encode=0, but not the sanitizeSafe()!
/proc/sanitizeSafe(var/input, var/max_length = MAX_MESSAGE_LEN, var/encode = 1, var/trim = 1, var/extra = 1)
return sanitize(replace_characters(input, list(">"=" ","<"=" ", "\""="'")), max_length, encode, trim, extra)
return sanitize(replace_characters(input, list(">"=" ","<"=" ", "\""="'")), max_length, encode, trim, extra)