1
0
Эх сурвалжийг харах

Bug 2045: Do not reset protocol to WebDAV when S3 protocol is selected and HTTP URL is pasted on the Login dialog

https://winscp.net/tracker/2045
(cherry picked from commit 07dc911b000a684d4088cee9ae35ce6586ce6e19)

Source commit: 396a8455d9fc0412ebc84503492a04c4d6c80e09
Martin Prikryl 3 жил өмнө
parent
commit
2c6c6e07db

+ 6 - 3
source/core/SessionData.cpp

@@ -2037,6 +2037,7 @@ bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options,
   int DefaultProtocolPortNumber;
   int DefaultProtocolPortNumber;
   TFtps AFtps = ftpsNone;
   TFtps AFtps = ftpsNone;
   int ProtocolLen = 0;
   int ProtocolLen = 0;
+  bool HttpForWebdav = FLAGCLEAR(Flags, pufPreferProtocol) || (FSProtocol != fsS3);
   if (IsProtocolUrl(Url, ScpProtocol, ProtocolLen))
   if (IsProtocolUrl(Url, ScpProtocol, ProtocolLen))
   {
   {
     AFSProtocol = fsSCPonly;
     AFSProtocol = fsSCPonly;
@@ -2076,7 +2077,7 @@ bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options,
     ProtocolDefined = true;
     ProtocolDefined = true;
   }
   }
   else if (IsProtocolUrl(Url, WebDAVProtocol, ProtocolLen) ||
   else if (IsProtocolUrl(Url, WebDAVProtocol, ProtocolLen) ||
-           IsProtocolUrl(Url, HttpProtocol, ProtocolLen))
+           (HttpForWebdav && IsProtocolUrl(Url, HttpProtocol, ProtocolLen)))
   {
   {
     AFSProtocol = fsWebDAV;
     AFSProtocol = fsWebDAV;
     AFtps = ftpsNone;
     AFtps = ftpsNone;
@@ -2085,7 +2086,7 @@ bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options,
     ProtocolDefined = true;
     ProtocolDefined = true;
   }
   }
   else if (IsProtocolUrl(Url, WebDAVSProtocol, ProtocolLen) ||
   else if (IsProtocolUrl(Url, WebDAVSProtocol, ProtocolLen) ||
-           IsProtocolUrl(Url, HttpsProtocol, ProtocolLen))
+           (HttpForWebdav && IsProtocolUrl(Url, HttpsProtocol, ProtocolLen)))
   {
   {
     AFSProtocol = fsWebDAV;
     AFSProtocol = fsWebDAV;
     AFtps = ftpsImplicit;
     AFtps = ftpsImplicit;
@@ -2093,7 +2094,9 @@ bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options,
     MoveStr(Url, MaskedUrl, ProtocolLen);
     MoveStr(Url, MaskedUrl, ProtocolLen);
     ProtocolDefined = true;
     ProtocolDefined = true;
   }
   }
-  else if (IsProtocolUrl(Url, S3Protocol, ProtocolLen))
+  else if (IsProtocolUrl(Url, S3Protocol, ProtocolLen) ||
+           IsProtocolUrl(Url, HttpProtocol, ProtocolLen) || // sic
+           IsProtocolUrl(Url, HttpsProtocol, ProtocolLen))
   {
   {
     AFSProtocol = fsS3;
     AFSProtocol = fsS3;
     AFtps = ftpsImplicit;
     AFtps = ftpsImplicit;

+ 1 - 0
source/core/SessionData.h

@@ -54,6 +54,7 @@ enum TParseUrlFlags
 {
 {
   pufAllowStoredSiteWithProtocol = 0x01,
   pufAllowStoredSiteWithProtocol = 0x01,
   pufUnsafe = 0x02,
   pufUnsafe = 0x02,
+  pufPreferProtocol = 0x04,
 };
 };
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 extern const UnicodeString CipherNames[CIPHER_COUNT];
 extern const UnicodeString CipherNames[CIPHER_COUNT];

+ 1 - 2
source/forms/Login.cpp

@@ -3077,9 +3077,8 @@ void __fastcall TLoginDialog::ParseUrl(const UnicodeString & Url)
 
 
   // We do not want to pass in StoredSessions as we do not want the URL be
   // We do not want to pass in StoredSessions as we do not want the URL be
   // parsed as pointing to a stored site.
   // parsed as pointing to a stored site.
-  // It also prevents resetting to defaults (do we want this?)
   bool DefaultsOnly; // unused
   bool DefaultsOnly; // unused
-  SessionData->ParseUrl(Url, NULL, NULL, DefaultsOnly, NULL, NULL, NULL, 0);
+  SessionData->ParseUrl(Url, NULL, NULL, DefaultsOnly, NULL, NULL, NULL, pufPreferProtocol);
 
 
   LoadSession(SessionData.get());
   LoadSession(SessionData.get());
 }
 }