浏览代码

Issue 2293 – Cannot download from WebDAV server when the request is redirected to the same path on another server

https://winscp.net/tracker/2293

Source commit: ee1e5d6c1ee72afb9e1feffcf6f4f7fc7a7aa86d
Martin Prikryl 1 年之前
父节点
当前提交
53e15d05be
共有 2 个文件被更改,包括 9 次插入4 次删除
  1. 8 4
      source/core/WebDAVFileSystem.cpp
  2. 1 0
      source/core/WebDAVFileSystem.h

+ 8 - 4
source/core/WebDAVFileSystem.cpp

@@ -800,9 +800,14 @@ int __fastcall TWebDAVFileSystem::ReadDirectoryInternal(
   return Result;
 }
 //---------------------------------------------------------------------------
+bool TWebDAVFileSystem::IsRedirect(int NeonStatus)
+{
+  return (NeonStatus == NE_REDIRECT);
+}
+//---------------------------------------------------------------------------
 bool __fastcall TWebDAVFileSystem::IsValidRedirect(int NeonStatus, UnicodeString & Path)
 {
-  bool Result = (NeonStatus == NE_REDIRECT);
+  bool Result = IsRedirect(NeonStatus);
   if (Result)
   {
     // What PathToNeon does
@@ -813,7 +818,6 @@ bool __fastcall TWebDAVFileSystem::IsValidRedirect(int NeonStatus, UnicodeString
     UnicodeString RedirectUrl = GetRedirectUrl();
     // We should test if the redirect is not for another server,
     // though not sure how to do this reliably (domain aliases, IP vs. domain, etc.)
-    // If this ever gets implemented, beware of use from Sink(), where we support redirects to another server.
     UnicodeString RedirectPath = ParsePathFromUrl(RedirectUrl);
     Result =
       !RedirectPath.IsEmpty() &&
@@ -1766,8 +1770,8 @@ void __fastcall TWebDAVFileSystem::Sink(
 
       ClearNeonError();
       int NeonStatus = ne_get(FSessionContext->NeonSession, PathToNeon(FileName), FD);
-      UnicodeString DiscardPath = FileName;
-      if (IsValidRedirect(NeonStatus, DiscardPath))
+      // Contrary to other actions, for "GET" we support any redirect
+      if (IsRedirect(NeonStatus))
       {
         UnicodeString CorrectedUrl = GetRedirectUrl();
         UTF8String CorrectedFileName, Query;

+ 1 - 0
source/core/WebDAVFileSystem.h

@@ -191,6 +191,7 @@ private:
   int __fastcall ReadDirectoryInternal(const UnicodeString & Path, TRemoteFileList * FileList);
   int __fastcall RenameFileInternal(const UnicodeString & FileName, const UnicodeString & NewName, bool Overwrite);
   int __fastcall CopyFileInternal(const UnicodeString & FileName, const UnicodeString & NewName, bool Overwrite);
+  bool IsRedirect(int NeonStatus);
   bool __fastcall IsValidRedirect(int NeonStatus, UnicodeString & Path);
   UnicodeString __fastcall DirectoryPath(UnicodeString Path);
   UnicodeString __fastcall FilePath(const TRemoteFile * File);