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

jsedding pushed a commit to branch 
jsedding/SLING-12366-read-inputstream-from-closed-session
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-xss.git

commit 5a9849ecdf2820945b047bfabd85b8bed2c671c3
Author: Julian Sedding <jsedd...@apache.org>
AuthorDate: Tue Jul 2 16:42:43 2024 +0200

    SLING-12368 - regression: rule for "ol" tag fails on java 9+ after 
SLING-12276
    
    - simplify implementation and fix by avoiding the call to
      AttributeBuilder#matching(boolean, java.lang.String...)
---
 .../sling/xss/impl/AntiSamyPolicyAdapter.java      | 28 ++--------------------
 1 file changed, 2 insertions(+), 26 deletions(-)

diff --git a/src/main/java/org/apache/sling/xss/impl/AntiSamyPolicyAdapter.java 
b/src/main/java/org/apache/sling/xss/impl/AntiSamyPolicyAdapter.java
index cc0a381..27f1911 100644
--- a/src/main/java/org/apache/sling/xss/impl/AntiSamyPolicyAdapter.java
+++ b/src/main/java/org/apache/sling/xss/impl/AntiSamyPolicyAdapter.java
@@ -135,23 +135,9 @@ public class AntiSamyPolicyAdapter {
                         List<String> literalList = attribute.getLiterals();
                         List<Pattern> patternList = attribute.getPatternList();
 
-                        if (!literalList.isEmpty() && !patternList.isEmpty()) {
-                            // if both, the patterns and the literals are not 
empty, the value should be checked with them with an OR and not with an AND.
-                            policyBuilder.allowAttributes(attribute.getName())
+                        policyBuilder.allowAttributes(attribute.getName())
                                 
.matching(matchesPatternsOrLiterals(patternList, true, literalList))
                                 .onElements(tag.getValue().getName());
-                        }
-                        else if (!literalList.isEmpty()) {
-                            policyBuilder.allowAttributes(attribute.getName())
-                                .matching(true, literalList.toArray(new 
String[0]))
-                                .onElements(tag.getValue().getName());
-                            
policyBuilder.allowAttributes(attribute.getName()).onElements(tag.getValue().getName());
-                        }
-                        else if (!patternList.isEmpty()) {
-                            policyBuilder.allowAttributes(attribute.getName())
-                                    .matching(matchesToPatterns(patternList))
-                                    .onElements(tag.getValue().getName());
-                        }
                     }
 
                     if (!styleSeen) {
@@ -236,17 +222,7 @@ public class AntiSamyPolicyAdapter {
         return new AttributePolicy() {
             @Override
             public @Nullable String apply(String elementName, String 
attributeName, String value) {
-                if (!literalList.isEmpty() && !patternList.isEmpty()) {
-                    return matchesPatternsOrLiterals(patternList, ignoreCase, 
literalList).test(value) ? value : null;
-
-                } else if (!literalList.isEmpty()) {
-                    value = ignoreCase ? value.toLowerCase() : value;
-                    return literalList.contains(value) ? value : null;
-
-                } else if (!patternList.isEmpty()) {
-                    return matchesToPatterns(patternList).test(value) ? value 
: null;
-                }
-                return null;
+                return matchesPatternsOrLiterals(patternList, ignoreCase, 
literalList).test(value) ? value : null;
             }
         };
     }

Reply via email to