mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use double quotes to fix possible issue
This commit is contained in:
parent
a2be6e0d0e
commit
50a8e888f0
1 changed files with 29 additions and 2 deletions
|
|
@ -590,7 +590,7 @@ namespace Flow.Launcher
|
|||
var result = Win32Helper.RunAsDesktopUser(
|
||||
Constant.CommandExecutablePath,
|
||||
Environment.CurrentDirectory,
|
||||
$"-StartProcess -FileName {filePath} -WorkingDirectory {workingDirectory} -Arguments {arguments} -UseShellExecute {useShellExecute} -Verb {verb}",
|
||||
$"-StartProcess -FileName {AddDoubleQuotes(filePath)} -WorkingDirectory {AddDoubleQuotes(workingDirectory)} -Arguments {AddDoubleQuotes(arguments)} -UseShellExecute {useShellExecute} -Verb {AddDoubleQuotes(verb)}",
|
||||
out var errorInfo);
|
||||
if (!string.IsNullOrEmpty(errorInfo))
|
||||
{
|
||||
|
|
@ -619,7 +619,34 @@ namespace Flow.Launcher
|
|||
}
|
||||
|
||||
public bool StartProcess(string filePath, string workingDirectory = "", Collection<string> argumentList = null, bool useShellExecute = true, string verb = "") =>
|
||||
StartProcess(filePath, workingDirectory, argumentList == null ? string.Empty : string.Join(" ", argumentList), useShellExecute, verb);
|
||||
StartProcess(filePath, workingDirectory, JoinArgumentList(argumentList), useShellExecute, verb);
|
||||
|
||||
private static string AddDoubleQuotes(string arg)
|
||||
{
|
||||
if (string.IsNullOrEmpty(arg))
|
||||
return "\"\"";
|
||||
|
||||
// If already wrapped in double quotes, return as is
|
||||
if (arg.Length >= 2 && arg[0] == '"' && arg[^1] == '"')
|
||||
return arg;
|
||||
|
||||
return $"\"{arg}\"";
|
||||
}
|
||||
|
||||
private static string JoinArgumentList(Collection<string> args)
|
||||
{
|
||||
if (args == null || args.Count == 0)
|
||||
return string.Empty;
|
||||
|
||||
return string.Join(" ", args.Select(arg =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(arg))
|
||||
return "\"\"";
|
||||
|
||||
// Add double quotes
|
||||
return AddDoubleQuotes(arg);
|
||||
}));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue