Issue #1529: detect klink.exe and putty.exe as variants of plink executable

This commit is contained in:
Ansgar Becker
2022-02-09 20:08:44 +01:00
parent 0bbca8e6f7
commit d84f2ed22e
2 changed files with 18 additions and 1 deletions

View File

@ -310,6 +310,7 @@ type
function getFirstWord(text: String; MustStartWithWordChar: Boolean=True): String;
function RegExprGetMatch(Expression: String; var Input: String; ReturnMatchNum: Integer; DeleteFromSource, CaseInsensitive: Boolean): String; Overload;
function RegExprGetMatch(Expression: String; Input: String; ReturnMatchNum: Integer): String; Overload;
function ExecRegExprI(const ARegExpr, AInputStr: RegExprString): Boolean;
function FormatByteNumber( Bytes: Int64; Decimals: Byte = 1 ): String; Overload;
function FormatByteNumber( Bytes: String; Decimals: Byte = 1 ): String; Overload;
function FormatTimeNumber(Seconds: Double; DisplaySeconds: Boolean): String;
@ -1021,6 +1022,22 @@ begin
end;
function ExecRegExprI(const ARegExpr, AInputStr: RegExprString): Boolean;
var
r: TRegExpr;
begin
Result := False;
r := TRegExpr.Create;
r.ModifierI := True;
try
r.Expression := ARegExpr;
Result := r.Exec(AInputStr);
finally
r.Free;
end;
end;
{**
Format a filesize to automatically use the best fitting expression
16 100 000 Bytes -> 16,1 MB

View File

@ -1085,7 +1085,7 @@ begin
// Build SSH command line
// plink bob@domain.com -pw myPassw0rd1 -P 22 -i "keyfile.pem" -L 55555:localhost:3306
IsPlink := FConnection.Parameters.SSHExe.ToLowerInvariant.Contains('plink');
IsPlink := ExecRegExprI('([pk]link|putty)', FConnection.Parameters.SSHExe);
SshCmd := FConnection.Parameters.SSHExe;
if IsPlink then
SshCmd := SshCmd + ' -ssh';