浏览代码

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

https://winscp.net/tracker/1958

Source commit: b819b4ecb31616bffbbb4392debdd2cc11637d7f
Martin Prikryl 4 年之前
父节点
当前提交
3bb78c2893
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      source/core/S3FileSystem.cpp

+ 4 - 3
source/core/S3FileSystem.cpp

@@ -937,12 +937,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());