This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 1ee03e7632 Use getPathPrefix() consistently
1ee03e7632 is described below

commit 1ee03e7632233c2ce7d11fcc5287e0764d65ff14
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Oct 3 14:36:47 2024 +0100

    Use getPathPrefix() consistently
    
    If WebDAV editing is enabled at a sepcific sub-path, getPathPrefix()
    needs to be used to ensure paths are processed correctly.
---
 java/org/apache/catalina/servlets/WebdavServlet.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java 
b/java/org/apache/catalina/servlets/WebdavServlet.java
index 2065add225..62b588a789 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -1469,14 +1469,14 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
         }
 
         // Cross-context operations aren't supported
-        String reqContextPath = req.getContextPath();
+        String reqContextPath = getPathPrefix(req);
         if (!destinationPath.startsWith(reqContextPath + "/")) {
             resp.sendError(WebdavStatus.SC_FORBIDDEN);
             return false;
         }
 
         // Remove context path & servlet path
-        destinationPath = destinationPath.substring(reqContextPath.length() + 
req.getServletPath().length());
+        destinationPath = destinationPath.substring(reqContextPath.length());
 
         if (debug > 0) {
             log("Dest path: " + destinationPath);
@@ -1827,7 +1827,7 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
             generatedXML.writeElement("D", "response", XMLWriter.OPENING);
 
             generatedXML.writeElement("D", "href", XMLWriter.OPENING);
-            generatedXML.writeText(req.getContextPath() + errorPath);
+            generatedXML.writeText(getPathPrefix(req) + errorPath);
             generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
 
             generatedXML.writeElement("D", "status", XMLWriter.OPENING);
@@ -1869,7 +1869,7 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
             return;
         }
 
-        String href = req.getContextPath() + req.getServletPath();
+        String href = getPathPrefix(req);
         if ((href.endsWith("/")) && (path.startsWith("/"))) {
             href += path.substring(1);
         } else {


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to