diff --git a/TGServerService/ChatCommands.cs b/TGServerService/ChatCommands.cs index a5401130f6..a3ecf0d5cd 100644 --- a/TGServerService/ChatCommands.cs +++ b/TGServerService/ChatCommands.cs @@ -55,7 +55,7 @@ namespace TGServerService protected override ExitCode Run(IList parameters) { - var res = Instance.SendCommand(String.Format("{0};sender={1};custom={2}", Keyword, CommandInfo.Value.Speaker, String.Join(" ", parameters))); + var res = Instance.SendCommand(String.Format("{0};sender={1};custom={2}", Keyword, CommandInfo.Value.Speaker, TGStationServer.SanitizeTopicString(String.Join(" ", parameters)))); if (res != "SUCCESS" && !String.IsNullOrWhiteSpace(res)) OutputProc(res); return ExitCode.Normal; diff --git a/TGServerService/DreamDaemon.cs b/TGServerService/DreamDaemon.cs index 5bb4037634..0d822de64e 100644 --- a/TGServerService/DreamDaemon.cs +++ b/TGServerService/DreamDaemon.cs @@ -520,7 +520,7 @@ namespace TGServerService /// public string WorldAnnounce(string message) { - var res = SendCommand(SCWorldAnnounce + ";message=" + message); + var res = SendCommand(SCWorldAnnounce + ";message=" + SanitizeTopicString(message)); if (res == "SUCCESS") return null; return res; diff --git a/TGServerService/Interop.cs b/TGServerService/Interop.cs index 9d466b9781..5c8040162c 100644 --- a/TGServerService/Interop.cs +++ b/TGServerService/Interop.cs @@ -154,11 +154,15 @@ namespace TGServerService return !(GameAPIVersion == null || GameAPIVersion < MinAPIVersion || GameAPIVersion > MaxAPIVersion); } + public static string SanitizeTopicString(string input) + { + return input.Replace("%", "%25").Replace("=", "%3d").Replace(";", "%3b").Replace("&", "%26").Replace("+", "%2b"); + } + //Fuckery to diddle byond with the right packet to accept our girth string SendTopic(string topicdata, ushort port) { //santize the escape characters in accordance with http://www.byond.com/docs/ref/info.html#/proc/params2list - topicdata = topicdata.Replace("%", "%25").Replace("=", "%3d").Replace(";", "%3b").Replace("&", "%26"); lock (topicLock) { if (!CheckAPIVersionConstraints()) return "Incompatible API!";