Bug 69363 - WebdavServlet#parseProperties() incorrectly calculates href
Summary: WebdavServlet#parseProperties() incorrectly calculates href
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 9.0.95
Hardware: All All
: P2 major (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-02 09:33 UTC by Michael Osipov
Modified: 2024-10-03 13:58 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Osipov 2024-10-02 09:33:10 UTC
WebdavServlet overrides both getRelativePath() and getPathPrefix() to remount th entire application. If you derive a new servlet from that and reinstantiate the behavior of the DefautServlet this line https://github.com/apache/tomcat/blob/142c45a4271e1fd8d400196a883fb560ebded110/java/org/apache/catalina/servlets/WebdavServlet.java#L1851 will break it and return invalid paths in multi-status responses. I bet this is an oversight. The fix is trivial:
> -        String href = req.getContextPath() + req.getServletPath();
> +        String href = getPathPrefix(req);

which I can apply if no one objects.
Comment 2 Remy Maucherat 2024-10-03 10:02:07 UTC
And https://github.com/apache/tomcat/blob/142c45a4271e1fd8d400196a883fb560ebded110/java/org/apache/catalina/servlets/WebdavServlet.java#L1809 should also probably use getPathPrefix(req) instead of simply req.getContextPath() because the servlet path is clearly not in the errorPath already.
Comment 3 Remy Maucherat 2024-10-03 10:07:12 UTC
Last, https://github.com/apache/tomcat/blob/142c45a4271e1fd8d400196a883fb560ebded110/java/org/apache/catalina/servlets/WebdavServlet.java#L1461 should simply use getPathPrefix(req). Only checking the context path is not enough (if there is a servlet path and it doesn't match, it's not going to work later).
Comment 4 Mark Thomas 2024-10-03 10:49:40 UTC
Hmm. With these changes implemented I am seeing a failure in the basic Litmus WebDAV tests. I'm investigating...
Comment 5 Mark Thomas 2024-10-03 13:28:45 UTC
Not an issue. There was a bug in the test suite and I just needed to pull the latest code. I'll get these changes committed shortly.
Comment 6 Mark Thomas 2024-10-03 13:40:33 UTC
Fixed in:
- 11.0.x for 11.0.0 onwards
- 10.1.x for 10.1.31 onwards
-  9.0.x for  9.0.96 onwards
Comment 7 Remy Maucherat 2024-10-03 13:58:48 UTC
(In reply to Mark Thomas from comment #5)
> Not an issue. There was a bug in the test suite and I just needed to pull
> the latest code. I'll get these changes committed shortly.

Good advice on the update, I was trying to compile 0.13 from http://www.webdav.org/neon/litmus/ which failed. Then 0.15 from the up to date location was having that put test fail (clearly not related to the change). Works after updating.