Przeglądaj źródła

* Allow user to completely manage quoting himself. Fixes issue #41329

Michaël Van Canneyt 1 miesiąc temu
rodzic
commit
3310a49ce0

+ 4 - 0
packages/fcl-process/src/processbody.inc

@@ -144,6 +144,7 @@ Type
     FXTermProgram: String;
     FPipeBufferSize : cardinal;
     FDescriptors: Array [TProcessHandleType] of TIODescriptor;
+    FSkipCommandLineQuotes : Boolean;
     function GetDescriptor(AIndex: Integer): TIODescriptor;
     Function  GetExitStatus : Integer;
     Function  GetExitCode : Integer;
@@ -231,6 +232,8 @@ Type
     Property StartupOptions : TStartupOptions Read FStartupOptions Write FStartupOptions;
     Property Running : Boolean Read GetRunning;
     Property ShowWindow : TShowWindowOptions Read FShowWindow Write SetShowWindow;
+    // This option is only used on windows. When set to True, the quoting of executable and parameters is skipped when constructing the command-line.
+    Property SkipCommandLineQuotes : Boolean Read FSkipCommandLineQuotes Write FSkipCommandLineQuotes;
     Property WindowColumns : Cardinal Read dwXCountChars Write SetWindowColumns;
     Property WindowHeight : Cardinal Read dwYSize Write SetWindowHeight;
     Property WindowLeft : Cardinal Read dwX Write SetWindowLeft;
@@ -402,6 +405,7 @@ begin
   FParameters:=TProcessStringList.Create;
   FRunCommandSleepTime:=100;
   FOnRunCommandEvent:=@IntOnIdleSleep;
+  FSkipCommandLineQuotes:=False;
   For HT in TProcessHandleType do
     FDescriptors[HT]:=CreateIODescriptor(Self,HT)
 end;

+ 11 - 2
packages/fcl-process/src/win/process.inc

@@ -208,9 +208,18 @@ Var
     WCommandLine:=FCommandLine
   else if (FExecutable<>'') then
     begin
-    Cmd:=MaybeQuoteIfNotQuoted(Executable);
+    if FSkipCommandLineQuotes then
+      Cmd:=Executable
+    else
+      Cmd:=MaybeQuoteIfNotQuoted(Executable);
     For I:=0 to Parameters.Count-1 do
-      Cmd:=Cmd+' '+MaybeQuoteIfNotQuoted(Parameters[i]);
+      begin
+      Cmd:=Cmd+' ';
+      if FSkipCommandLineQuotes then
+        Cmd:=Cmd+Parameters[i]
+      else
+        Cmd:=Cmd+MaybeQuoteIfNotQuoted(Parameters[i]);
+      end;
     WCommandLine:=Cmd;
     end;
   If FCurrentDirectory<>'' then