You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2024/05/23 12:30:06 UTC
(tomcat) branch 9.0.x updated (f6d7d02984 -> 365535db88)
This is an automated email from the ASF dual-hosted git repository.
markt pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
from f6d7d02984 Sync FFM for 9.0
new 5ba3e76797 Add support for shallow copies when using WebDAV
new 365535db88 Move infinite copy test to include all recurrsive code
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../apache/catalina/servlets/WebdavServlet.java | 53 ++++++++++++++--------
webapps/docs/changelog.xml | 7 +++
2 files changed, 42 insertions(+), 18 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 02/02: Move infinite copy test to include all recurrsive code
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 365535db8833cf0c36342c9c2633ea4d4eecad63
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu May 23 13:26:46 2024 +0100
Move infinite copy test to include all recurrsive code
Review by kkolinko
---
.../apache/catalina/servlets/WebdavServlet.java | 26 +++++++++++-----------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java b/java/org/apache/catalina/servlets/WebdavServlet.java
index c5a4111f51..ccdebc338e 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -1585,19 +1585,19 @@ public class WebdavServlet extends DefaultServlet implements PeriodicEventListen
}
}
- String[] entries = resources.list(source);
- for (String entry : entries) {
- String childDest = dest;
- if (!childDest.equals("/")) {
- childDest += "/";
- }
- childDest += entry;
- String childSrc = source;
- if (!childSrc.equals("/")) {
- childSrc += "/";
- }
- childSrc += entry;
- if (infiniteCopy) {
+ if (infiniteCopy) {
+ String[] entries = resources.list(source);
+ for (String entry : entries) {
+ String childDest = dest;
+ if (!childDest.equals("/")) {
+ childDest += "/";
+ }
+ childDest += entry;
+ String childSrc = source;
+ if (!childSrc.equals("/")) {
+ childSrc += "/";
+ }
+ childSrc += entry;
copyResource(errorList, childSrc, childDest, true);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 01/02: Add support for shallow copies when using WebDAV
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 5ba3e76797babe431f16878825e2a6a192e18863
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue May 21 12:54:40 2024 +0100
Add support for shallow copies when using WebDAV
---
.../apache/catalina/servlets/WebdavServlet.java | 31 +++++++++++++++++-----
webapps/docs/changelog.xml | 7 +++++
2 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java b/java/org/apache/catalina/servlets/WebdavServlet.java
index fe26facb05..c5a4111f51 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -1518,7 +1518,20 @@ public class WebdavServlet extends DefaultServlet implements PeriodicEventListen
Map<String,Integer> errorList = new HashMap<>();
- boolean result = copyResource(errorList, path, destinationPath);
+ boolean infiniteCopy = true;
+ String depthHeader = req.getHeader("Depth");
+ if (depthHeader != null) {
+ if (depthHeader.equals("infinity")) {
+ // NO-OP - this is the default
+ } else if (depthHeader.equals("0")) {
+ infiniteCopy = false;
+ } else {
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST);
+ return false;
+ }
+ }
+
+ boolean result = copyResource(errorList, path, destinationPath, infiniteCopy);
if ((!result) || (!errorList.isEmpty())) {
if (errorList.size() == 1) {
@@ -1547,16 +1560,18 @@ public class WebdavServlet extends DefaultServlet implements PeriodicEventListen
/**
* Copy a collection.
*
- * @param errorList Hashtable containing the list of errors which occurred during the copy operation
- * @param source Path of the resource to be copied
- * @param dest Destination path
+ * @param errorList Map containing the list of errors which occurred during the copy operation
+ * @param source Path of the resource to be copied
+ * @param dest Destination path
+ * @param infiniteCopy {@code true} if this copy is to be an infinite copy, otherwise {@code false} for a shallow
+ * copy
*
* @return <code>true</code> if the copy was successful
*/
- private boolean copyResource(Map<String,Integer> errorList, String source, String dest) {
+ private boolean copyResource(Map<String,Integer> errorList, String source, String dest, boolean infiniteCopy) {
if (debug > 1) {
- log("Copy: " + source + " To: " + dest);
+ log("Copy: " + source + " To: " + dest + " Infinite: " + infiniteCopy);
}
WebResource sourceResource = resources.getResource(source);
@@ -1582,7 +1597,9 @@ public class WebdavServlet extends DefaultServlet implements PeriodicEventListen
childSrc += "/";
}
childSrc += entry;
- copyResource(errorList, childSrc, childDest);
+ if (infiniteCopy) {
+ copyResource(errorList, childSrc, childDest, true);
+ }
}
} else if (sourceResource.isFile()) {
WebResource destResource = resources.getResource(dest);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 956a1af8fc..541b3a9613 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -105,6 +105,13 @@
issues do not "pop up" wrt. others).
-->
<section name="Tomcat 9.0.90 (remm)" rtext="in development">
+ <subsection name="Catalina">
+ <changelog>
+ <add>
+ Add support for shallow copies when using WebDAV. (markt)
+ </add>
+ </changelog>
+ </subsection>
<subsection name="Other">
<changelog>
<update>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org