From e9abd76acc6f924b9a8d808e1e4123572b29fec0 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Wed, 8 May 2019 02:50:56 -0400 Subject: [PATCH] [mod_webdav] workaround Microsoft-WebDAV-MiniRedir workaround Microsoft-WebDAV-MiniRedir bugs --- src/mod_webdav.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/mod_webdav.c b/src/mod_webdav.c index 68d20435..592df188 100644 --- a/src/mod_webdav.c +++ b/src/mod_webdav.c @@ -3742,6 +3742,14 @@ mod_webdav_propfind (connection * const con, const plugin_config * const pconf) } else if (S_ISDIR(pb.st.st_mode)) { if (con->physical.path->ptr[con->physical.path->used - 2] != '/') { + buffer *vb = http_header_request_get(con, HTTP_HEADER_OTHER, + CONST_STR_LEN("User-Agent")); + if (vb && 0 == strncmp(vb->ptr, "Microsoft-WebDAV-MiniRedir/", + sizeof("Microsoft-WebDAV-MiniRedir/")-1)) { + /* workaround Microsoft-WebDAV-MiniRedir bug */ + http_response_redirect_to_directory(pconf->srv, con, 308); + return HANDLER_FINISHED; + } /* set "Content-Location" instead of sending 308 redirect to dir */ if (!http_response_redirect_to_directory(pconf->srv, con, 0)) return HANDLER_FINISHED; @@ -4914,6 +4922,16 @@ mod_webdav_proppatch (connection * const con, const plugin_config * const pconf) if (S_ISDIR(st.st_mode)) { if (con->physical.path->ptr[con->physical.path->used - 2] != '/') { + buffer *vb = http_header_request_get(con, HTTP_HEADER_OTHER, + CONST_STR_LEN("User-Agent")); + if (vb && 0 == strncmp(vb->ptr, "Microsoft-WebDAV-MiniRedir/", + sizeof("Microsoft-WebDAV-MiniRedir/")-1)) { + /* workaround Microsoft-WebDAV-MiniRedir bug */ + /* (might not be necessary for PROPPATCH here, + * but match behavior in mod_webdav_propfind() for PROPFIND) */ + http_response_redirect_to_directory(pconf->srv, con, 308); + return HANDLER_FINISHED; + } /* set "Content-Location" instead of sending 308 redirect to dir */ if (!http_response_redirect_to_directory(pconf->srv, con, 0)) return HANDLER_FINISHED; @@ -5023,6 +5041,16 @@ mod_webdav_proppatch (connection * const con, const plugin_config * const pconf) if (NULL == ms ? webdav_db_transaction_commit(pconf) : webdav_db_transaction_rollback(pconf)) { + if (NULL == ms) { + buffer *vb = http_header_request_get(con, HTTP_HEADER_OTHER, + CONST_STR_LEN("User-Agent")); + if (vb && 0 == strncmp(vb->ptr, "Microsoft-WebDAV-MiniRedir/", + sizeof("Microsoft-WebDAV-MiniRedir/")-1)) { + /* workaround Microsoft-WebDAV-MiniRedir bug; 204 not handled */ + ms = buffer_init(); /* 207 Multi-status */ + webdav_xml_response_status(ms, con->physical.path, 200); + } + } if (NULL == ms) http_status_set_fin(con, 204); /* No Content */ else /* 207 Multi-status */ -- 2.11.4.GIT