From 6ea3e198b2c8ad443897c0c9858d1f835cded44d Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Mon, 7 Sep 2020 13:38:31 -0400 Subject: [PATCH] Escape arguments with spaces in event scripts --- .../Components/StaticFiles/Configuration.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs index de5bfb0174..5805339a58 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs @@ -480,7 +480,17 @@ namespace Tgstation.Server.Host.Components.StaticFiles using (var script = processExecutor.LaunchProcess( ioManager.ConcatPath(resolvedScriptsDir, I), resolvedScriptsDir, - String.Join(' ', parameters), + String.Join( + ' ', + parameters.Select(arg => + { + if (!arg.Contains(' ', StringComparison.Ordinal)) + return arg; + + arg = arg.Replace("\"", "\\\"", StringComparison.Ordinal); + + return $"\"{arg}\""; + })), true, true, true))