Dew it right

This commit is contained in:
Cyberboss
2017-10-03 16:13:12 -04:00
parent 28cf3b9376
commit 3009655c18
3 changed files with 7 additions and 3 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ namespace TGServerService
protected override ExitCode Run(IList<string> 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;
+1 -1
View File
@@ -520,7 +520,7 @@ namespace TGServerService
/// <inheritdoc />
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;
+5 -1
View File
@@ -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!";