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:
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,6 @@ class TStoredSessionList;
|
||||
class TSessionData : public TNamedObject
|
||||
{
|
||||
friend class TStoredSessionList;
|
||||
|
||||
private:
|
||||
UnicodeString FHostName;
|
||||
int FPortNumber;
|
||||
|
||||
Reference in New Issue
Block a user