1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00

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

(cherry picked from commit 6954eeb7fc)

# Conflicts:
#	source/core/SessionData.cpp

Source commit: 75f3609faeda0b6c15891e204f781b9d74fca554
This commit is contained in:
Martin Prikryl
2021-04-23 14:27:11 +00:00
parent 496dfb31d7
commit 5639643832
3 changed files with 17 additions and 1 deletions

View File

@@ -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));

View File

@@ -1893,6 +1893,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)
@@ -2116,6 +2123,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 = APortNumber;
}

View File

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