Browse Source

Issue 2321 – Compatibility with new OneDrive WebDAV interface (2nd)

https://winscp.net/tracker/2321

– Ignoring empty text/xml 207 MULTI-STATUS response to MKCOL request
– Special comma-encoding of directories do not seem to happen anymore

Source commit: 86ab2712ebb7202d44a39866dd601cae4d891f28
Martin Prikryl 11 months ago
parent
commit
03bf4e7047

+ 4 - 0
libs/neon/src/ne_basic.c

@@ -524,6 +524,10 @@ int ne_mkcol(ne_session *sess, const char *path)
     ne_lock_using_parent(req, real_path);
 #endif
     
+    #ifdef WINSCP
+    // New OneDrive interface returns empty text/xml 207 MULTI-STATUS response, ignore it
+    ne_set_request_flag(req, NE_REQFLAG_IGNOREEMPTYXML, 1);
+    #endif
     ret = ne_simple_request(sess, req);
 
     ne_free(real_path);

+ 4 - 0
libs/neon/src/ne_request.h

@@ -243,6 +243,10 @@ typedef enum ne_request_flag_e {
                              * timeout when reading interim
                              * responses. */
 
+    #ifdef WINSCP
+    NE_REQFLAG_IGNOREEMPTYXML,
+    #endif
+
     NE_REQFLAG_LAST /* enum sentinel value */
 } ne_request_flag;
 

+ 11 - 0
libs/neon/src/ne_xmlreq.c

@@ -44,8 +44,14 @@ int ne_xml_parse_response(ne_request *req, ne_xml_parser *parser)
     char buf[8000];
     ssize_t bytes;
     int ret = 0;
+    #ifdef WINSCP
+    int any = 0;
+    #endif
 
     while ((bytes = ne_read_response_block(req, buf, sizeof buf)) > 0) {
+        #ifdef WINSCP
+        any = 1;
+        #endif
         ret = ne_xml_parse(parser, buf, bytes);
         if (ret)
             return parse_error(ne_get_session(req), parser);
@@ -53,6 +59,11 @@ int ne_xml_parse_response(ne_request *req, ne_xml_parser *parser)
 
     if (bytes == 0) {
         /* Tell the parser that end of document was reached: */
+        #ifdef WINSCP
+        if (!any && ne_get_request_flag(req, NE_REQFLAG_IGNOREEMPTYXML))
+            return NE_OK;
+        else
+        #endif
         if (ne_xml_parse(parser, NULL, 0) == 0)
             return NE_OK;
         else

+ 3 - 1
source/core/WebDAVFileSystem.cpp

@@ -1059,7 +1059,9 @@ void __fastcall TWebDAVFileSystem::ParsePropResultSet(TRemoteFile * File,
     // 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 the * (and others) is removed from file names.
-    // Filenames with commas (,) get as many additional characters at the end of the filename as there are commas.
+
+    // Filenames with commas (,) get as many additional characters at the end of the filename as there are commas
+    // (not true anymore in the new interface).
     if (FOneDrive &&
         (ContainsText(File->FileName, L"^") || ContainsText(File->FileName, L",") || (wcspbrk(File->DisplayName.c_str(), L"&,+#[]%*") != NULL)))
     {