You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2020/02/11 09:10:11 UTC

[sling-org-apache-sling-security] branch master updated: SLING-8838 - Add HEAD support to ContentDispositionFilter

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-security.git


The following commit(s) were added to refs/heads/master by this push:
     new 3c602bb  SLING-8838 - Add HEAD support to ContentDispositionFilter
3c602bb is described below

commit 3c602bb95f17977c20f238f6f14b9833e084bca9
Author: Ilyas Stéphane Türkben <tu...@adobe.com>
AuthorDate: Mon Jan 13 15:29:17 2020 +0100

    SLING-8838 - Add HEAD support to ContentDispositionFilter
---
 .../apache/sling/security/impl/ContentDispositionFilter.java   | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/sling/security/impl/ContentDispositionFilter.java b/src/main/java/org/apache/sling/security/impl/ContentDispositionFilter.java
index 474344a..4962495 100644
--- a/src/main/java/org/apache/sling/security/impl/ContentDispositionFilter.java
+++ b/src/main/java/org/apache/sling/security/impl/ContentDispositionFilter.java
@@ -51,6 +51,8 @@ public class ContentDispositionFilter implements Filter {
     /** Logger. */
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
+    private static final List<String> supportedMethods = Arrays.asList("GET", "HEAD");
+
     /**
      * Set of paths
      */
@@ -81,7 +83,7 @@ public class ContentDispositionFilter implements Filter {
                 if (path.length() > 0) {
                     int idx = path.indexOf('*');
                     int colonIdx = path.indexOf(":");
-    
+
                     if (colonIdx > -1 && colonIdx < idx) {
                         // ':'  in paths is not allowed
                         logger.info("wildcard ('*') in content type is not allowed, but found content type with value '{}'", path.substring(colonIdx));
@@ -109,7 +111,7 @@ public class ContentDispositionFilter implements Filter {
                             contentTypesMap.put(p, contentTypes);
                         }
                     }
-    
+
                 }
             }
         }
@@ -202,14 +204,14 @@ public class ContentDispositionFilter implements Filter {
          */
         @Override
         public void setContentType(String type) {
-            if ("GET".equals(request.getMethod())) {
+            if (supportedMethods.contains(request.getMethod())) {
                 String previousContentType = (String) request.getAttribute(ATTRIBUTE_NAME);
 
                 if (previousContentType != null && previousContentType.equals(type)) {
                     super.setContentType(type);
                     return;
                 }
-                
+
                 request.setAttribute(ATTRIBUTE_NAME, type);
 
                 String resourcePath = resource.getPath();