jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1818251 - in /jackrabbit/branches/2.8: ./ jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
Date Fri, 15 Dec 2017 09:37:27 GMT
Author: reschke
Date: Fri Dec 15 09:37:27 2017
New Revision: 1818251

URL: http://svn.apache.org/viewvc?rev=1818251&view=rev
Log:
JCR-4165: jackrabbit-server doesn't handle content-codings properly (ported to 2.8)

Reject all requests with non-empty Content-Encoding header fields with status 415.

Modified:
    jackrabbit/branches/2.8/   (props changed)
    jackrabbit/branches/2.8/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java

Propchange: jackrabbit/branches/2.8/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec 15 09:37:27 2017
@@ -1,3 +1,3 @@
 /jackrabbit/branches/JCR-2272:1173165-1176545
 /jackrabbit/sandbox/JCR-2415-lucene-3.0:1060860-1064038
-/jackrabbit/trunk:1592881,1597717,1597799,1597806,1598035,1598058,1603769,1603934,1609712,1615997,1625561,1627529,1634584,1653275,1667787,1674859,1680757,1709811,1717599,1729382,1732436,1740814-1740815,1751279,1752165,1758600,1759607,1759782,1759865,1761679,1761909,1762422,1763558,1766398,1771078,1771741,1771939,1771999,1772049,1772444,1772457,1772530,1772544,1773579,1773591,1773745,1774443,1775657,1779166,1779460,1780208,1786325,1787043,1787381,1792193,1793315,1793323,1793327,1793332,1796980,1797209,1797917,1798586,1799429,1811667,1814831,1817097
+/jackrabbit/trunk:1592881,1597717,1597799,1597806,1598035,1598058,1603769,1603934,1609712,1615997,1625561,1627529,1634584,1653275,1667787,1674859,1680757,1709811,1717599,1729382,1732436,1740814-1740815,1751279,1752165,1758600,1759607,1759782,1759865,1761679,1761909,1762422,1763558,1766398,1771078,1771741,1771939,1771999,1772049,1772444,1772457,1772530,1772544,1773579,1773591,1773745,1774443,1775657,1779166,1779460,1780208,1786325,1787043,1787381,1792193,1793315,1793323,1793327,1793332,1796980,1797209,1797917,1798586,1799429,1802977,1811667,1814831,1817097

Modified: jackrabbit/branches/2.8/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.8/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java?rev=1818251&r1=1818250&r2=1818251&view=diff
==============================================================================
--- jackrabbit/branches/2.8/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
(original)
+++ jackrabbit/branches/2.8/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
Fri Dec 15 09:37:27 2017
@@ -88,6 +88,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
 import java.util.List;
 
 /**
@@ -282,6 +284,17 @@ abstract public class AbstractWebdavServ
                 return;
             }
 
+            // JCR-4165: reject any content-coding in request until we can
+            // support it (see JCR-4166)
+            List<String> ces = getContentCodings(request);
+            if (!ces.isEmpty()) {
+                webdavResponse.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
+                webdavResponse.setHeader("Accept-Encoding", "identity");
+                webdavResponse.setContentType("text/plain; charset=UTF-8");
+                webdavResponse.getWriter().println("Content-Encodings not supported, but
received: " + ces);
+                webdavResponse.getWriter().flush();
+            }
+
             // check matching if=header for lock-token relevant operations
             DavResource resource = getResourceFactory().createResource(webdavRequest.getRequestLocator(),
webdavRequest, webdavResponse);
             if (!isPreconditionValid(webdavRequest, resource)) {
@@ -1389,4 +1402,21 @@ abstract public class AbstractWebdavServ
     protected OutputContext getOutputContext(DavServletResponse response, OutputStream out)
{
         return new OutputContextImpl(response, out);
     }
+
+    private List<String> getContentCodings(HttpServletRequest request) {
+        List<String> result = Collections.emptyList();
+        for (@SuppressWarnings("unchecked")
+        Enumeration<String> ceh = request.getHeaders("Content-Encoding"); ceh.hasMoreElements();)
{
+            for (String h : ceh.nextElement().split(",")) {
+                if (!h.trim().isEmpty()) {
+                    if (result.isEmpty()) {
+                        result = new ArrayList<String>();
+                    }
+                    result.add(h.trim());
+                }
+            }
+        }
+
+        return result;
+    }
 }



Mime
View raw message