Adds Internet admin midi (#30457)
* Adds Internet admin midi * Moves global regex into proc (shell_url_scrub) * Moves shelleo to world Adds quotes around the command in shelleo, to encapsulate it * Admins can stop playing web sounds * Revised internet midi extension order Moved m4a to least preferred, as it can potentially carry non-aac or non-mpeg-3 audio * Kills \n in web sound * play_web_sound availability based on config * play web sound and shelleo tweaks istypeless for in play web sound & readability parenthesis around binary AND add return index defines for shelleo proc * Security fix for play web sound
This commit is contained in:
committed by
CitadelStationBot
parent
ce787e7726
commit
00dd2f283b
@@ -0,0 +1,57 @@
|
||||
//Runs the command in the system's shell, returns a list of (error code, stdout, stderr)
|
||||
|
||||
#define SHELLEO_NAME "data/shelleo."
|
||||
#define SHELLEO_ERR ".err"
|
||||
#define SHELLEO_OUT ".out"
|
||||
/world/proc/shelleo(command)
|
||||
var/static/list/shelleo_ids = list()
|
||||
var/stdout = ""
|
||||
var/stderr = ""
|
||||
var/errorcode = 1
|
||||
var/shelleo_id
|
||||
var/out_file = ""
|
||||
var/err_file = ""
|
||||
var/static/list/interpreters = list("[MS_WINDOWS]" = "cmd /c", "[UNIX]" = "sh -c")
|
||||
var/interpreter = interpreters["[world.system_type]"]
|
||||
if(interpreter)
|
||||
for(var/seo_id in shelleo_ids)
|
||||
if(!shelleo_ids[seo_id])
|
||||
shelleo_ids[seo_id] = TRUE
|
||||
shelleo_id = "[seo_id]"
|
||||
break
|
||||
if(!shelleo_id)
|
||||
shelleo_id = "[shelleo_ids.len + 1]"
|
||||
shelleo_ids += shelleo_id
|
||||
shelleo_ids[shelleo_id] = TRUE
|
||||
out_file = "[SHELLEO_NAME][shelleo_id][SHELLEO_OUT]"
|
||||
err_file = "[SHELLEO_NAME][shelleo_id][SHELLEO_ERR]"
|
||||
errorcode = shell("[interpreter] \"[command]\" > [out_file] 2> [err_file]")
|
||||
if(fexists(out_file))
|
||||
stdout = file2text(out_file)
|
||||
fdel(out_file)
|
||||
if(fexists(err_file))
|
||||
stderr = file2text(err_file)
|
||||
fdel(err_file)
|
||||
shelleo_ids[shelleo_id] = FALSE
|
||||
else
|
||||
CRASH("Operating System: [world.system_type] not supported") // If you encounter this error, you are encouraged to update this proc with support for the new operating system
|
||||
. = list(errorcode, stdout, stderr)
|
||||
#undef SHELLEO_NAME
|
||||
#undef SHELLEO_ERR
|
||||
#undef SHELLEO_OUT
|
||||
|
||||
/proc/shell_url_scrub(url)
|
||||
var/static/regex/bad_chars_regex = regex("\[^#%&./:=?\\w]*", "g")
|
||||
var/scrubbed_url = ""
|
||||
var/bad_match = ""
|
||||
var/last_good = 1
|
||||
var/bad_chars = 1
|
||||
do
|
||||
bad_chars = bad_chars_regex.Find(url)
|
||||
scrubbed_url += copytext(url, last_good, bad_chars)
|
||||
if(bad_chars)
|
||||
bad_match = url_encode(bad_chars_regex.match)
|
||||
scrubbed_url += bad_match
|
||||
last_good = bad_chars + length(bad_match)
|
||||
while(bad_chars)
|
||||
. = scrubbed_url
|
||||
Reference in New Issue
Block a user