This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new 31672fe435 Fix BZ 69362 - Better multi-status response for deletes
31672fe435 is described below
commit 31672fe4356e30ffc1c1abc0258fefcbbbc0dc81
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Oct 3 11:25:47 2024 +0100
Fix BZ 69362 - Better multi-status response for deletes
---
java/org/apache/catalina/servlets/WebdavServlet.java | 16 +++++++++++++---
webapps/docs/changelog.xml | 5 +++++
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java
b/java/org/apache/catalina/servlets/WebdavServlet.java
index e7383cb176..611a85c88c 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -1778,9 +1778,19 @@ public class WebdavServlet extends DefaultServlet
implements PeriodicEventListen
}
if (!childResource.delete()) {
- if (!childResource.isDirectory()) {
- // If it's not a collection, then it's an unknown
- // error
+ /*
+ * See RFC 4918, section 9.6.1, last paragraph.
+ *
+ * If a child resource can't be deleted then the parent
resource SHOULD NOT be included in the
+ * multi-status response since the notice of the failure
to delete the child implies that all
+ * parent resources could also not be deleted.
+ */
+ if (!childResource.isDirectory() ||
resources.list(childName).length == 0) {
+ /*
+ * The resource could not be deleted. If the resource
is not a directory or if the resource is a
+ * directory and it has no children (or all those
children have been successfully deleted) then
+ * it should be listed in the multi-status response.
+ */
errorList.put(childName,
Integer.valueOf(WebdavStatus.SC_METHOD_NOT_ALLOWED));
}
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 379c556720..7852df94dd 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -160,6 +160,11 @@
Add log warning if non wildcard mappings are used with the
<code>WebdavServlet</code>. (remm)
</fix>
+ <fix>
+ <bug>69362</bug>: Provide a better multi-status response when deleting
a
+ collection via WebDAV fails. Empty directories that cannot be deleted
+ will now be included in the response. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]