From 306e677979a8fd2902cf38b1a0ec83bb7873f3c2 Mon Sep 17 00:00:00 2001 From: Tastyfish Date: Sat, 20 Feb 2016 00:00:11 -0500 Subject: [PATCH 1/3] Fixes sanitize_simple() to work and makes our repo compile in 510 --- code/__HELPERS/bygex/bygex.dm | 2 ++ code/__HELPERS/text.dm | 20 +++++++++---------- .../scripting/Implementations/Telecomms.dm | 4 ++-- .../scripting/Implementations/_Logic.dm | 8 +++++++- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/code/__HELPERS/bygex/bygex.dm b/code/__HELPERS/bygex/bygex.dm index c5c4999ccca..a59f3cecd6b 100644 --- a/code/__HELPERS/bygex/bygex.dm +++ b/code/__HELPERS/bygex/bygex.dm @@ -48,11 +48,13 @@ regex_replaceall(str, exp, fmt) return call(LIBREGEX_LIBRARY, "regex_replaceall")(str, exp, fmt) +#if DM_VERSION < 510 replacetextEx(str, exp, fmt) return call(LIBREGEX_LIBRARY, "regEx_replaceallliteral")(str, exp, fmt) replacetext(str, exp, fmt) return call(LIBREGEX_LIBRARY, "regex_replaceallliteral")(str, exp, fmt) +#endif regEx_replace(str, exp, fmt) return call(LIBREGEX_LIBRARY, "regEx_replace")(str, exp, fmt) diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm index 5b720291b48..83564676bad 100644 --- a/code/__HELPERS/text.dm +++ b/code/__HELPERS/text.dm @@ -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) @@ -214,8 +214,8 @@ proc/checkhtml(var/t) /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 +320,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 +350,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 +365,10 @@ proc/checkhtml(var/t) //alternative copytext() for encoded text, doesn't break html entities (" 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 > < &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 &), 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) \ No newline at end of file + return sanitize(replace_characters(input, list(">"=" ","<"=" ", "\""="'")), max_length, encode, trim, extra) \ No newline at end of file diff --git a/code/modules/scripting/Implementations/Telecomms.dm b/code/modules/scripting/Implementations/Telecomms.dm index eadc1d398c4..eafe0c94bd3 100644 --- a/code/modules/scripting/Implementations/Telecomms.dm +++ b/code/modules/scripting/Implementations/Telecomms.dm @@ -138,7 +138,7 @@ @param replacestring: the string to replace the substring with */ - interpreter.SetProc("replace", /proc/replacetext) + interpreter.SetProc("replace", /proc/n_replacetext) /* -> Locates an element/substring inside of a list or string @@ -194,7 +194,7 @@ interpreter.SetProc("reverse", /proc/reverse_text) interpreter.SetProc("tonum", /proc/n_str2num) interpreter.SetProc("capitalize", /proc/capitalize) - interpreter.SetProc("replacetextEx",/proc/replacetextEx) + interpreter.SetProc("replacetextEx",/proc/n_replacetextEx) // Numbers interpreter.SetProc("tostring", /proc/n_num2str) diff --git a/code/modules/scripting/Implementations/_Logic.dm b/code/modules/scripting/Implementations/_Logic.dm index c71839eaad9..eb27ecce04d 100644 --- a/code/modules/scripting/Implementations/_Logic.dm +++ b/code/modules/scripting/Implementations/_Logic.dm @@ -260,4 +260,10 @@ proc/n_round(var/num) /proc/n_log(var/num) if(isnum(num) && 0 < num) - return log(num) \ No newline at end of file + return log(num) + +/proc/n_replacetext(text, r, with) + return replacetext(text, r, with) + +/proc/n_replacetextEx(text, r, with) + return replacetextEx(text, r, with) \ No newline at end of file From 6b366668964a75a0a926d12e3e4602a62488f8f6 Mon Sep 17 00:00:00 2001 From: Tastyfish Date: Sat, 20 Feb 2016 02:05:26 -0500 Subject: [PATCH 2/3] Also makes 510 work if BYGEX off --- code/__HELPERS/text.dm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm index 83564676bad..288af19c4a3 100644 --- a/code/__HELPERS/text.dm +++ b/code/__HELPERS/text.dm @@ -204,12 +204,14 @@ proc/checkhtml(var/t) */ // See bygex.dm #ifndef USE_BYGEX +#if DM_VERSION < 510 /proc/replacetext(text, find, replacement) return list2text(text2list(text, find), replacement) /proc/replacetextEx(text, find, replacement) return list2text(text2listEx(text, find), replacement) #endif +#endif /proc/replace_characters(var/t,var/list/repl_chars) for(var/char in repl_chars) From 0149791eafad338243c87db1df15fafaffe11122 Mon Sep 17 00:00:00 2001 From: Tastyfish Date: Wed, 24 Feb 2016 03:50:59 -0500 Subject: [PATCH 3/3] Removes 510 stuff for now --- code/__HELPERS/bygex/bygex.dm | 2 -- code/__HELPERS/text.dm | 3 --- code/modules/scripting/Implementations/Telecomms.dm | 4 ++-- code/modules/scripting/Implementations/_Logic.dm | 8 +------- 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/code/__HELPERS/bygex/bygex.dm b/code/__HELPERS/bygex/bygex.dm index a59f3cecd6b..c5c4999ccca 100644 --- a/code/__HELPERS/bygex/bygex.dm +++ b/code/__HELPERS/bygex/bygex.dm @@ -48,13 +48,11 @@ regex_replaceall(str, exp, fmt) return call(LIBREGEX_LIBRARY, "regex_replaceall")(str, exp, fmt) -#if DM_VERSION < 510 replacetextEx(str, exp, fmt) return call(LIBREGEX_LIBRARY, "regEx_replaceallliteral")(str, exp, fmt) replacetext(str, exp, fmt) return call(LIBREGEX_LIBRARY, "regex_replaceallliteral")(str, exp, fmt) -#endif regEx_replace(str, exp, fmt) return call(LIBREGEX_LIBRARY, "regEx_replace")(str, exp, fmt) diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm index 288af19c4a3..fc00a9dcf3b 100644 --- a/code/__HELPERS/text.dm +++ b/code/__HELPERS/text.dm @@ -204,15 +204,12 @@ proc/checkhtml(var/t) */ // See bygex.dm #ifndef USE_BYGEX -#if DM_VERSION < 510 /proc/replacetext(text, find, replacement) return list2text(text2list(text, find), replacement) /proc/replacetextEx(text, find, replacement) return list2text(text2listEx(text, find), replacement) #endif -#endif - /proc/replace_characters(var/t,var/list/repl_chars) for(var/char in repl_chars) t = replacetext(t, char, repl_chars[char]) diff --git a/code/modules/scripting/Implementations/Telecomms.dm b/code/modules/scripting/Implementations/Telecomms.dm index eafe0c94bd3..eadc1d398c4 100644 --- a/code/modules/scripting/Implementations/Telecomms.dm +++ b/code/modules/scripting/Implementations/Telecomms.dm @@ -138,7 +138,7 @@ @param replacestring: the string to replace the substring with */ - interpreter.SetProc("replace", /proc/n_replacetext) + interpreter.SetProc("replace", /proc/replacetext) /* -> Locates an element/substring inside of a list or string @@ -194,7 +194,7 @@ interpreter.SetProc("reverse", /proc/reverse_text) interpreter.SetProc("tonum", /proc/n_str2num) interpreter.SetProc("capitalize", /proc/capitalize) - interpreter.SetProc("replacetextEx",/proc/n_replacetextEx) + interpreter.SetProc("replacetextEx",/proc/replacetextEx) // Numbers interpreter.SetProc("tostring", /proc/n_num2str) diff --git a/code/modules/scripting/Implementations/_Logic.dm b/code/modules/scripting/Implementations/_Logic.dm index eb27ecce04d..c71839eaad9 100644 --- a/code/modules/scripting/Implementations/_Logic.dm +++ b/code/modules/scripting/Implementations/_Logic.dm @@ -260,10 +260,4 @@ proc/n_round(var/num) /proc/n_log(var/num) if(isnum(num) && 0 < num) - return log(num) - -/proc/n_replacetext(text, r, with) - return replacetext(text, r, with) - -/proc/n_replacetextEx(text, r, with) - return replacetextEx(text, r, with) \ No newline at end of file + return log(num) \ No newline at end of file