]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix sandbox check failure when compiling with latest .NET SDK. (#28077)
authorPieter-Jan Briers <pieterjan.briers+git@gmail.com>
Thu, 16 May 2024 17:55:32 +0000 (19:55 +0200)
committerGitHub <noreply@github.com>
Thu, 16 May 2024 17:55:32 +0000 (19:55 +0200)
Roslyn now compiles char + string with string.Concat(ROS<char>). This means doing ref char -> ROS<char> which is not sandbox safe. Actually fixing this in the sandboxer is difficult so I'm gonna just pass on that for now.

Content.Client/RCD/RCDMenu.xaml.cs
Content.Shared/Chat/SharedChatSystem.cs

index 51ec66ea44464737d5dab9b175483d47e696f3b2..3eb0397a6908b640b0e1849030017299b12bde28 100644 (file)
@@ -68,7 +68,7 @@ public sealed partial class RCDMenu : RadialMenu
                 tooltip = Loc.GetString(entProto.Name);
             }
 
-            tooltip = char.ToUpper(tooltip[0]) + tooltip.Remove(0, 1);
+            tooltip = OopsConcat(char.ToUpper(tooltip[0]).ToString(), tooltip.Remove(0, 1));
 
             var button = new RCDMenuButton()
             {
@@ -119,6 +119,12 @@ public sealed partial class RCDMenu : RadialMenu
         SendRCDSystemMessageAction += bui.SendRCDSystemMessage;
     }
 
+    private static string OopsConcat(string a, string b)
+    {
+        // This exists to prevent Roslyn being clever and compiling something that fails sandbox checks.
+        return a + b;
+    }
+
     private void AddRCDMenuButtonOnClickActions(Control control)
     {
         var radialContainer = control as RadialContainer;
index e61d93efaeb1d49434d6fa7bfe5383913c608f41..4f0b1465cd2b2f0fecab9f9cb86371165886384d 100644 (file)
@@ -152,10 +152,16 @@ public abstract class SharedChatSystem : EntitySystem
         if (string.IsNullOrEmpty(message))
             return message;
         // Capitalize first letter
-        message = char.ToUpper(message[0]) + message.Remove(0, 1);
+        message = OopsConcat(char.ToUpper(message[0]).ToString(), message.Remove(0, 1));
         return message;
     }
 
+    private static string OopsConcat(string a, string b)
+    {
+        // This exists to prevent Roslyn being clever and compiling something that fails sandbox checks.
+        return a + b;
+    }
+
     public string SanitizeMessageCapitalizeTheWordI(string message, string theWordI = "i")
     {
         if (string.IsNullOrEmpty(message))