我在创建的 Windows 服务中使用Process.Start来执行我在服务器上用于音频转换的 exe。我将一些用户输入作为参数传递给这个 exe。代码看起来像这样:
string filePath = "\ffmpeg.exe";
string parameters = String.Format(@"-i ""{0}"" -f mp3 ""{1}""",
LocalFileName,
tempDirectory + NewFileName);
ProcessStartInfo startInfo = new ProcessStartInfo(ffmpegPath, parameters);
Process proc = Process.Start(startInfo);
变量LocalFileName和NewFileName由用户输入设置。如果我想防止OS Injection,删除任何&字符就足够了,还是我应该做的更多?