Ver código fonte

Bug 1958: Failure when S3 bucket contains a subfolder with an empty name

https://winscp.net/tracker/1958
(cherry picked from commit 3bb78c2893eacb02de3a0721883ae7daef2d3abb)

Source commit: 68d5ba6920d0d12d9b75c7613588b7315a30acee
Martin Prikryl 4 anos atrás
pai
commit
11bff6a98b
1 arquivos alterados com 4 adições e 3 exclusões
  1. 4 3
      source/core/S3FileSystem.cpp

+ 4 - 3
source/core/S3FileSystem.cpp

@@ -832,12 +832,13 @@ S3Status TS3FileSystem::LibS3ListBucketCallback(
   for (int Index = 0; Index < CommonPrefixesCount; Index++)
   {
     UnicodeString CommonPrefix = StrFromS3(CommonPrefixes[Index]);
-    // Reported only by one user, but should do no harm.
-    if (CommonPrefix != L"/")
+    UnicodeString FileName = UnixExtractFileName(UnixExcludeTrailingBackslash(CommonPrefix));
+    // Have seen prefixes like "/" or "path/subpath//"
+    if (!FileName.IsEmpty())
     {
       std::unique_ptr<TRemoteFile> File(new TRemoteFile(NULL));
       File->Terminal = Data.FileSystem->FTerminal;
-      File->FileName = UnixExtractFileName(UnixExcludeTrailingBackslash(CommonPrefix));
+      File->FileName = FileName;
       File->Type = FILETYPE_DIRECTORY;
       File->ModificationFmt = mfNone;
       Data.FileList->AddFile(File.release());