Browse Source

https:// URL with known S3 API hostname (s3.amazonaws.com, digitaloceanspaces.com, storage.googleapis.com) is interpreted as S3 protocol, instead of WebDAV

Source commit: 02beab5d3a11b731f8ff37c0186c04b8dedd375e
Martin Prikryl 4 năm trước cách đây
mục cha
commit
6954eeb7fc
3 tập tin đã thay đổi với 17 bổ sung1 xóa
  1. 3 0
      dotnet/SessionOptions.cs
  2. 14 0
      source/core/SessionData.cpp
  3. 0 1
      source/core/SessionData.h

+ 3 - 0
dotnet/SessionOptions.cs

@@ -182,6 +182,9 @@ namespace WinSCP
                 portNumber = hostInfo;
             }
 
+            // Contrary to TSessionData::ParseUrl, not converting Webdav to S3 on S3 hostname.
+            // Not sure if it is desirable and WinSCP will do the conversion for us later anyway.
+
             if (string.IsNullOrEmpty(HostName))
             {
                 throw new ArgumentException("No host name", nameof(url));

+ 14 - 0
source/core/SessionData.cpp

@@ -1908,6 +1908,13 @@ void __fastcall TSessionData::MaskPasswords()
   }
 }
 //---------------------------------------------------------------------
+static bool IsDomainOrSubdomain(const UnicodeString & FullDomain, const UnicodeString & Domain)
+{
+  return
+    SameText(FullDomain, Domain) ||
+    EndsText(L"." + Domain, FullDomain);
+}
+//---------------------------------------------------------------------
 bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options,
   TStoredSessionList * StoredSessions, bool & DefaultsOnly, UnicodeString * FileName,
   bool * AProtocolDefined, UnicodeString * MaskedUrl, int Flags)
@@ -2131,6 +2138,13 @@ bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options,
       }
       else if (ProtocolDefined)
       {
+        if ((AFSProtocol == fsWebDAV) &&
+            (IsDomainOrSubdomain(HostName, S3LibDefaultHostName()) ||
+             IsDomainOrSubdomain(HostName, L"digitaloceanspaces.com") ||
+             IsDomainOrSubdomain(HostName, L"storage.googleapis.com")))
+        {
+          AFSProtocol = fsS3;
+        }
         PortNumber = DefaultProtocolPortNumber;
       }
 

+ 0 - 1
source/core/SessionData.h

@@ -101,7 +101,6 @@ class TStoredSessionList;
 class TSessionData : public TNamedObject
 {
 friend class TStoredSessionList;
-
 private:
   UnicodeString FHostName;
   int FPortNumber;