From 0f88cfed41ac4bcb2763c0b9933ae3dc835735ac Mon Sep 17 00:00:00 2001 From: marco Date: Wed, 30 May 2012 17:25:20 +0000 Subject: [PATCH] * if arguments and exename already quoted, then assume the user did it properly. Mantis #22040 git-svn-id: trunk@21436 - --- packages/fcl-process/src/win/process.inc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/fcl-process/src/win/process.inc b/packages/fcl-process/src/win/process.inc index bebddb6fa2..b0c532e10a 100644 --- a/packages/fcl-process/src/win/process.inc +++ b/packages/fcl-process/src/win/process.inc @@ -206,6 +206,14 @@ begin Result:=S; end; +Function MaybeQuoteIfNotQuoted(Const S : String) : String; + +begin + If (Pos(' ',S)<>0) and (pos('"',S)=0) then + Result:='"'+S+'"' + else + Result:=S; +end; Procedure TProcess.Execute; Var @@ -237,9 +245,9 @@ begin PCommandLine:=Pchar(FCommandLine) else if (Fexecutable<>'') then begin - Cmd:=MaybeQuote(Executable); + Cmd:=MaybeQuoteIfNotQuoted(Executable); For I:=0 to Parameters.Count-1 do - Cmd:=Cmd+' '+MaybeQuote(Parameters[i]); + Cmd:=Cmd+' '+MaybeQuoteIfNotQuoted(Parameters[i]); PCommandLine:=PChar(Cmd); end; If FCurrentDirectory<>'' then