Browse Source

Bug fix: When saving a site with a slash in the username, it is misinterpreted as a site folder

Source commit: 1fcd93d3772d1a867bb8c88a9532737188955d29
Martin Prikryl 4 years ago
parent
commit
a4e7ae98ff
1 changed files with 7 additions and 4 deletions
  1. 7 4
      source/core/SessionData.cpp

+ 7 - 4
source/core/SessionData.cpp

@@ -3067,27 +3067,30 @@ void __fastcall TSessionData::SetRekeyTime(unsigned int value)
 //---------------------------------------------------------------------
 UnicodeString __fastcall TSessionData::GetDefaultSessionName()
 {
+  UnicodeString Result;
   if (IsLocalBrowser)
   {
     // See also TScpCommanderForm::GetLocalBrowserSessionTitle
     UnicodeString Path1 = ExtractShortName(LocalDirectory, false);
     UnicodeString Path2 = ExtractShortName(OtherLocalDirectory, false);
-    return Path1 + TitleSeparator + Path2;
+    Result = Path1 + TitleSeparator + Path2;
   }
   else if (!HostName.IsEmpty() && !UserName.IsEmpty())
   {
     // If we ever choose to include port number,
     // we have to escape IPv6 literals in HostName
-    return FORMAT(L"%s@%s", (UserName, HostName));
+    Result = FORMAT(L"%s@%s", (UserName, HostName));
   }
   else if (!HostName.IsEmpty())
   {
-    return HostName;
+    Result = HostName;
   }
   else
   {
-    return L"session";
+    Result = L"session";
   }
+  Result = MakeValidName(Result);
+  return Result;
 }
 //---------------------------------------------------------------------
 UnicodeString __fastcall TSessionData::GetNameWithoutHiddenPrefix()