Browse Source

转定义字符问题

master
root 4 days ago
parent
commit
761a094d60
  1. 3
      CoreAgent.Infrastructure/Command/Executors/LinuxCommandExecutor.cs

3
CoreAgent.Infrastructure/Command/Executors/LinuxCommandExecutor.cs

@ -91,10 +91,9 @@ public class LinuxCommandExecutor : BaseCommandExecutor
throw new ArgumentException("命令不能为空", nameof(command)); throw new ArgumentException("命令不能为空", nameof(command));
} }
// 使用双引号包裹整个命令,并对特殊字符进行转义 // 使用双引号包裹整个命令,只对必要的特殊字符进行转义
var escapedCommand = command var escapedCommand = command
.Replace("\"", "\\\"") .Replace("\"", "\\\"")
.Replace("$", "\\$")
.Replace("`", "\\`") .Replace("`", "\\`")
.Replace("\\", "\\\\"); .Replace("\\", "\\\\");

Loading…
Cancel
Save