Skip to content

NTSL compile errors and save changes #6690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions monkestation/code/modules/NTSL/code/filter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 11 additions & 3 deletions monkestation/code/modules/NTSL/code/machinery/server.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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 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]"
if(!COOLDOWN_FINISHED(src, compile_cooldown))
return "Servers are recharging, please wait."
var/list/compileerrors = Compiler.Compile(rawcode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading