This is an automated email from the ASF dual-hosted git repository. kwin 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 1c8c11c SLING-7218 correctly deal with null values in configuration property array types 1c8c11c is described below commit 1c8c11c4c6c11d2fb9da0e15e50a8889663e05e8 Author: Konrad Windszus <k...@apache.org> AuthorDate: Tue Oct 31 14:41:21 2017 +0100 SLING-7218 correctly deal with null values in configuration property array types --- .../security/impl/ContentDispositionFilter.java | 67 +++++++++++----------- 1 file changed, 34 insertions(+), 33 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 454e5ff..8d53b7c 100644 --- a/src/main/java/org/apache/sling/security/impl/ContentDispositionFilter.java +++ b/src/main/java/org/apache/sling/security/impl/ContentDispositionFilter.java @@ -69,49 +69,50 @@ public class ContentDispositionFilter implements Filter { @Activate private void activate(ContentDispositionFilterConfiguration configuration) { - String[] contentDispositionPathsConfiguredValue = configuration.sling_content_disposition_paths(); Set<String> paths = new HashSet<String>(); List<String> pfxs = new ArrayList<String>(); Map<String, Set<String>> contentTypesMap = new HashMap<String, Set<String>>(); - for (String path : contentDispositionPathsConfiguredValue) { - path = path.trim(); - 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)); - } else { - String p = null; - if (idx >= 0) { - if (idx > 0) { - p = path.substring(0, idx); - pfxs.add(p); - } else { - // we don't allow "*" - that would defeat the - // purpose. - logger.info("catch-all wildcard for paths not allowed."); - } + // check for null till we upgrade to DS 1.4 (https://osgi.org/bugzilla/show_bug.cgi?id=208) + if (configuration.sling_content_disposition_paths() != null) { + for (String path : configuration.sling_content_disposition_paths()) { + path = path.trim(); + 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)); } else { - if (colonIdx > -1) { - p = path.substring(0, colonIdx); + String p = null; + if (idx >= 0) { + if (idx > 0) { + p = path.substring(0, idx); + pfxs.add(p); + } else { + // we don't allow "*" - that would defeat the + // purpose. + logger.info("catch-all wildcard for paths not allowed."); + } } else { - p = path; + if (colonIdx > -1) { + p = path.substring(0, colonIdx); + } else { + p = path; + } + paths.add(p); + } + if (colonIdx != -1 && p != null) { + Set <String> contentTypes = getContentTypes(path.substring(colonIdx+1)); + contentTypesMap.put(p, contentTypes); } - paths.add(p); - } - if (colonIdx != -1 && p != null) { - Set <String> contentTypes = getContentTypes(path.substring(colonIdx+1)); - contentTypesMap.put(p, contentTypes); } + } - } } - contentDispositionPaths = paths.isEmpty() ? Collections.<String>emptySet() : paths; contentDispositionPathsPfx = pfxs.toArray(new String[pfxs.size()]); contentTypesMapping = contentTypesMap.isEmpty()?Collections.<String, Set<String>>emptyMap(): contentTypesMap; @@ -119,9 +120,9 @@ public class ContentDispositionFilter implements Filter { enableContentDispositionAllPaths = configuration.sling_content_disposition_all_paths(); - String[] contentDispostionExcludedPathsArray = configuration.sling_content_disposition_excluded_paths(); + String[] contentDispositionExcludedPathsArray = configuration.sling_content_disposition_excluded_paths() != null ? configuration.sling_content_disposition_excluded_paths() : new String[]{}; - contentDispositionExcludedPaths = new HashSet<String>(Arrays.asList(contentDispostionExcludedPathsArray)); + contentDispositionExcludedPaths = new HashSet<String>(Arrays.asList(contentDispositionExcludedPathsArray)); logger.info("Initialized. content disposition paths: {}, content disposition paths-pfx {}, content disposition excluded paths: {}. Enable Content Disposition for all paths is set to {}", new Object[]{ contentDispositionPaths, contentDispositionPathsPfx, contentDispositionExcludedPaths, enableContentDispositionAllPaths} -- To stop receiving notification emails like this one, please contact ['"commits@sling.apache.org" <commits@sling.apache.org>'].