tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1820576 - in /tomcat/trunk: java/org/apache/catalina/servlets/WebdavServlet.java webapps/docs/changelog.xml
Date Mon, 08 Jan 2018 15:52:16 GMT
Author: markt
Date: Mon Jan  8 15:52:15 2018
New Revision: 1820576

URL: http://svn.apache.org/viewvc?rev=1820576&view=rev
Log:
When using WebDAV to copy a file resource to a destination that requires a collection to be
overwritten, ensure that the operation succeeds rather than fails (with a 500 response). This
enables Tomcat to pass two additional tests from the Litmus WebDAV test suite.

Modified:
    tomcat/trunk/java/org/apache/catalina/servlets/WebdavServlet.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/servlets/WebdavServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/servlets/WebdavServlet.java?rev=1820576&r1=1820575&r2=1820576&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/servlets/WebdavServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/servlets/WebdavServlet.java Mon Jan  8 15:52:15
2018
@@ -1742,19 +1742,23 @@ public class WebdavServlet extends Defau
                     }
                 }
             }
+            // WebDAV Litmus test attempts to copy/move a file over a collection
+            // Need to remove trailing / from destination to enable test to pass
+            if (!destResource.exists() && dest.endsWith("/") && dest.length()
> 1) {
+                // Convert destination name from collection (with trailing '/')
+                // to file (without trailing '/')
+                dest = dest.substring(0, dest.length() - 1);
+            }
             try (InputStream is = sourceResource.getInputStream()) {
-                if (!resources.write(dest, is,
-                        false)) {
-                    errorList.put(source,
-                            Integer.valueOf(WebdavStatus.SC_INTERNAL_SERVER_ERROR));
+                if (!resources.write(dest, is, false)) {
+                    errorList.put(source, Integer.valueOf(WebdavStatus.SC_INTERNAL_SERVER_ERROR));
                     return false;
                 }
             } catch (IOException e) {
                 log(sm.getString("webdavservlet.inputstreamclosefail", source), e);
             }
         } else {
-            errorList.put(source,
-                    Integer.valueOf(WebdavStatus.SC_INTERNAL_SERVER_ERROR));
+            errorList.put(source, Integer.valueOf(WebdavStatus.SC_INTERNAL_SERVER_ERROR));
             return false;
         }
         return true;

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1820576&r1=1820575&r2=1820576&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Mon Jan  8 15:52:15 2018
@@ -67,6 +67,12 @@
         <code>setHeader()</code> or <code>addHeader()</code> as well
as when it
         is set via <code>setContentType()</code>. (markt)
       </fix>
+      <fix>
+        When using WebDAV to copy a file resource to a destination that requires
+        a collection to be overwritten, ensure that the operation succeeds
+        rather than fails (with a 500 response). This enables Tomcat to pass two
+        additional tests from the Litmus WebDAV test suite. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



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


Mime
View raw message