Prechádzať zdrojové kódy

Bug 2085: Workaround for specific encoding of commas in filenames (and particularly directory names) by OneDrive WebDAV interface

https://winscp.net/tracker/2085
(cherry picked from commit 33bfa5d5515d8c2ec2f506baa4cb9de404442933)

Source commit: d5d932fa931f2b89f350fd0ef774101d384091ee
Martin Prikryl 3 rokov pred
rodič
commit
52aa8739cd
1 zmenil súbory, kde vykonal 11 pridanie a 6 odobranie
  1. 11 6
      source/core/WebDAVFileSystem.cpp

+ 11 - 6
source/core/WebDAVFileSystem.cpp

@@ -828,14 +828,17 @@ void TWebDAVFileSystem::NeonPropsResult(
   TReadFileData & Data = *static_cast<TReadFileData *>(UserData);
   TReadFileData & Data = *static_cast<TReadFileData *>(UserData);
   if (Data.FileList != NULL)
   if (Data.FileList != NULL)
   {
   {
-    UnicodeString FileListPath = Data.FileSystem->AbsolutePath(Data.FileList->Directory, false);
-    if (UnixSamePath(Path, FileListPath))
-    {
-      Path = UnixIncludeTrailingBackslash(UnixIncludeTrailingBackslash(Path) + PARENTDIRECTORY);
-    }
     std::unique_ptr<TRemoteFile> File(new TRemoteFile(NULL));
     std::unique_ptr<TRemoteFile> File(new TRemoteFile(NULL));
     File->Terminal = Data.FileSystem->FTerminal;
     File->Terminal = Data.FileSystem->FTerminal;
     Data.FileSystem->ParsePropResultSet(File.get(), Path, Results);
     Data.FileSystem->ParsePropResultSet(File.get(), Path, Results);
+
+    UnicodeString FileListPath = Data.FileSystem->AbsolutePath(Data.FileList->Directory, false);
+    if (UnixSamePath(File->FullFileName, FileListPath))
+    {
+      File->FileName = PARENTDIRECTORY;
+      File->FullFileName = UnixCombinePaths(Path, PARENTDIRECTORY);
+    }
+
     Data.FileList->AddFile(File.release());
     Data.FileList->AddFile(File.release());
   }
   }
   else
   else
@@ -947,7 +950,9 @@ void __fastcall TWebDAVFileSystem::ParsePropResultSet(TRemoteFile * File,
     // so if we see one in the display name, take the name from there.
     // so if we see one in the display name, take the name from there.
     // * and % won't help, as OneDrive seem to have bug with % at the end of the filename,
     // * and % won't help, as OneDrive seem to have bug with % at the end of the filename,
     // and the * (and others) is removed from file names.
     // and the * (and others) is removed from file names.
-    if (FOneDrive && (ContainsText(File->FileName, L"^") || (wcspbrk(File->DisplayName.c_str(), L"&,+#[]%*") != NULL)))
+    // Filenames with commas (,) get as many additional characters at the end of the filename as there are commas.
+    if (FOneDrive &&
+        (ContainsText(File->FileName, L"^") || ContainsText(File->FileName, L",") || (wcspbrk(File->DisplayName.c_str(), L"&,+#[]%*") != NULL)))
     {
     {
       File->FileName = File->DisplayName;
       File->FileName = File->DisplayName;
       File->FullFileName = UnixCombinePaths(UnixExtractFileDir(File->FullFileName), File->FileName);
       File->FullFileName = UnixCombinePaths(UnixExtractFileDir(File->FullFileName), File->FileName);