From dd871a3ce126680dfdc89ae661c0c883d886ed65 Mon Sep 17 00:00:00 2001 From: Scrambledeggs <113869252+Scrambledeggs00@users.noreply.github.com> Date: Wed, 14 May 2025 15:12:17 -0400 Subject: [PATCH 1/2] NTSL error fixes --- monkestation/code/modules/NTSL/code/filter.dm | 6 +----- .../code/modules/NTSL/code/machinery/server.dm | 14 +++++++++++--- .../modules/NTSL/code/machinery/traffic_control.dm | 1 + 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/monkestation/code/modules/NTSL/code/filter.dm b/monkestation/code/modules/NTSL/code/filter.dm index 3b6a0a7f2af5..a0e17932c629 100644 --- a/monkestation/code/modules/NTSL/code/filter.dm +++ b/monkestation/code/modules/NTSL/code/filter.dm @@ -49,18 +49,14 @@ return FALSE // No, it is pretty. //Returns null if there is any bad text in the string -/proc/reject_bad_ntsl_text(text, max_length = 512, ascii_only = TRUE, require_pretty = TRUE, allow_newline = FALSE, allow_code = FALSE) +/proc/reject_bad_ntsl_text(text, ascii_only = TRUE, require_pretty = TRUE, allow_newline = FALSE, allow_code = FALSE) if(require_pretty && isnotpretty(text)) return - var/char_count = 0 var/non_whitespace = FALSE var/lenbytes = length(text) var/char = "" for(var/i = 1, i <= lenbytes, i += length(char)) char = text[i] - char_count++ - if(char_count > max_length) - return switch(text2ascii(char)) if(9, 62, 60, 92, 47) // tab, <, >, \, / if(!allow_code) diff --git a/monkestation/code/modules/NTSL/code/machinery/server.dm b/monkestation/code/modules/NTSL/code/machinery/server.dm index bc15d2317015..53cd99422ce1 100644 --- a/monkestation/code/modules/NTSL/code/machinery/server.dm +++ b/monkestation/code/modules/NTSL/code/machinery/server.dm @@ -54,16 +54,24 @@ GLOBAL_LIST_EMPTY(tcomms_servers) update_logs() /obj/machinery/telecomms/server/proc/compile(mob/user = usr) as /list + ///Maximum amount of characters that can be in a script + var/max_characters = 15000 + ///The character count of the code being compiled + var/code_length = length(rawcode) + if(is_banned_from(user.ckey, JOB_SIGNAL_TECHNICIAN)) to_chat(user, span_warning("You are banned from using NTSL.")) return "Unauthorized access." - if(QDELETED(Compiler)) return - - if(!reject_bad_ntsl_text(rawcode, 20000, require_pretty = FALSE, allow_newline = TRUE, allow_code = TRUE)) + //Check if it has any bad characters in it + if(!reject_bad_ntsl_text(rawcode, require_pretty = FALSE, allow_newline = TRUE, allow_code = TRUE)) rawcode = null return "Please use galactic common characters only." + //Check if it is over the character limit which is 16000 due to TGUI having a hard time handling bigger scripts + if(code_length > max_characters) + rawcode = null + return "Over character limit: [code_length]/[max_characters]" if(!COOLDOWN_FINISHED(src, compile_cooldown)) return "Servers are recharging, please wait." var/list/compileerrors = Compiler.Compile(rawcode) diff --git a/monkestation/code/modules/NTSL/code/machinery/traffic_control.dm b/monkestation/code/modules/NTSL/code/machinery/traffic_control.dm index 38e27698da78..585cd9f2db5a 100644 --- a/monkestation/code/modules/NTSL/code/machinery/traffic_control.dm +++ b/monkestation/code/modules/NTSL/code/machinery/traffic_control.dm @@ -132,6 +132,7 @@ return TRUE if("save_code") storedcode = params["saved_code"] + compiler_output += "Code saved" return TRUE if("compile_code") if(!user_name) From 714198ea9bfc7a0053de1ca1582b578652fdf542 Mon Sep 17 00:00:00 2001 From: Scrambledeggs <113869252+Scrambledeggs00@users.noreply.github.com> Date: Wed, 14 May 2025 15:25:13 -0400 Subject: [PATCH 2/2] Forgot to change a comment --- monkestation/code/modules/NTSL/code/machinery/server.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkestation/code/modules/NTSL/code/machinery/server.dm b/monkestation/code/modules/NTSL/code/machinery/server.dm index 53cd99422ce1..706555e104b3 100644 --- a/monkestation/code/modules/NTSL/code/machinery/server.dm +++ b/monkestation/code/modules/NTSL/code/machinery/server.dm @@ -68,7 +68,7 @@ GLOBAL_LIST_EMPTY(tcomms_servers) if(!reject_bad_ntsl_text(rawcode, require_pretty = FALSE, allow_newline = TRUE, allow_code = TRUE)) rawcode = null return "Please use galactic common characters only." - //Check if it is over the character limit which is 16000 due to TGUI having a hard time handling bigger scripts + //Check if it is over the character limit which is 15000 due to TGUI having a hard time handling bigger scripts if(code_length > max_characters) rawcode = null return "Over character limit: [code_length]/[max_characters]"