Browse Source

TFilenameEdit does not add double quotes around path with spaces anymore

- fixes selecting client certificate with spaces and
- makes all uses of StripPathQuotes redundant - to be removed one day - keeping it in case some users have saved site with double quotes, but that's unlikely

Source commit: a5b400bdd9d38f383062f6315d09d92bd5662e46
Martin Prikryl 10 years ago
parent
commit
0a0b3c73ce

+ 1 - 0
source/core/Configuration.cpp

@@ -1284,6 +1284,7 @@ void __fastcall TConfiguration::SetRandomSeedFile(UnicodeString value)
 //---------------------------------------------------------------------
 UnicodeString __fastcall TConfiguration::GetRandomSeedFileName()
 {
+  // StripPathQuotes should not be needed as we do not feed quotes anymore
   return StripPathQuotes(ExpandEnvironmentVariables(FRandomSeedFile)).Trim();
 }
 //---------------------------------------------------------------------

+ 1 - 0
source/core/SecureShell.cpp

@@ -199,6 +199,7 @@ Conf * __fastcall TSecureShell::StoreToConfig(TSessionData * Data, bool Simple)
 
   UnicodeString SPublicKeyFile = Data->PublicKeyFile;
   if (SPublicKeyFile.IsEmpty()) SPublicKeyFile = Configuration->DefaultKeyFile;
+  // StripPathQuotes should not be needed as we do not feed quotes anymore
   SPublicKeyFile = StripPathQuotes(ExpandEnvironmentVariables(SPublicKeyFile));
   Filename * KeyFileFileName = filename_from_str(UTF8String(SPublicKeyFile).c_str());
   conf_set_filename(conf, CONF_keyfile, KeyFileFileName);

+ 3 - 0
source/core/SessionData.cpp

@@ -2125,6 +2125,7 @@ void __fastcall TSessionData::SetPublicKeyFile(UnicodeString value)
     // PublicKeyFile is key for Passphrase encryption
     UnicodeString XPassphrase = Passphrase;
 
+    // StripPathQuotes should not be needed as we do not feed quotes anymore
     FPublicKeyFile = StripPathQuotes(value);
     Modify();
 
@@ -3223,6 +3224,7 @@ void __fastcall TSessionData::SetTunnelPublicKeyFile(UnicodeString value)
 {
   if (FTunnelPublicKeyFile != value)
   {
+    // StripPathQuotes should not be needed as we do not feed quotes anymore
     FTunnelPublicKeyFile = StripPathQuotes(value);
     Modify();
   }
@@ -4219,6 +4221,7 @@ bool __fastcall TStoredSessionList::CanLogin(TSessionData * Data)
 //---------------------------------------------------------------------
 UnicodeString GetExpandedLogFileName(UnicodeString LogFileName, TSessionData * SessionData)
 {
+  // StripPathQuotes should not be needed as we do not feed quotes anymore
   UnicodeString ANewFileName = StripPathQuotes(ExpandEnvironmentVariables(LogFileName));
   TDateTime N = Now();
   for (int Index = 1; Index < ANewFileName.Length(); Index++)

+ 1 - 0
source/forms/SiteAdvanced.cpp

@@ -1278,6 +1278,7 @@ void __fastcall TSiteAdvancedDialog::FormCloseQuery(TObject * /*Sender*/,
 {
   if (ModalResult == DefaultResult(this))
   {
+    // StripPathQuotes should not be needed as we do not feed quotes anymore
     VerifyKeyIncludingVersion(StripPathQuotes(PrivateKeyEdit2->Text), GetSshProt());
     // for tunnel key do not check SSH version as it is not configurable
     VerifyKey(StripPathQuotes(TunnelPrivateKeyEdit2->Text));

+ 4 - 20
source/packages/my/ComboEdit.pas

@@ -978,21 +978,6 @@ begin
   end;
 end;
 
-function ClipFilename(const FileName: string): string;
-var
-  Params: string;
-begin
-  if FileExists(ApiPath(FileName)) then Result := FileName
-  else SplitCommandLine(FileName, Result, Params);
-end;
-
-function ExtFilename(const FileName: string): string;
-begin
-  if (Pos(' ', FileName) > 0) and (FileName[1] <> '"') then
-    Result := Format('"%s"', [FileName])
-  else Result := FileName;
-end;
-
 constructor TFilenameEdit.Create(AOwner: TComponent);
 begin
   inherited Create(AOwner);
@@ -1054,7 +1039,6 @@ begin
   inherited ButtonClick;
   Temp := inherited Text;
   Action := True;
-  Temp := ClipFilename(Temp);
   DoBeforeDialog(Temp, Action);
   if not Action then Exit;
   if ValidFileName(Temp) then
@@ -1078,20 +1062,20 @@ begin
   if CanFocus then SetFocus;
   DoAfterDialog(Temp, Action);
   if Action then begin
-    inherited Text := ExtFilename(Temp);
+    inherited Text := Temp;
     SetInitialDir(ExtractFilePath(FDialog.FileName));
   end;
 end;
 
 function TFilenameEdit.GetFileName: string;
 begin
-  Result := ClipFilename(inherited Text);
+  Result := inherited Text;
 end;
 
 procedure TFilenameEdit.SetFileName(const Value: string);
 begin
-  if (Value = '') or ValidFileName(ClipFilename(Value)) then begin
-    inherited Text := ExtFilename(Value);
+  if (Value = '') or ValidFileName(Value) then begin
+    inherited Text := Value;
     ClearFileList;
   end
   else raise EComboEditError.CreateFmt(SInvalidFilename, [Value]);