You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by GitBox <gi...@apache.org> on 2022/10/20 12:27:23 UTC

[GitHub] [sling-org-apache-sling-xss] nonanalou commented on a diff in pull request #30: SLING-11592 - Fix policy adapter condition chaining and add tests

nonanalou commented on code in PR #30:
URL: https://github.com/apache/sling-org-apache-sling-xss/pull/30#discussion_r1000558760


##########
src/main/java/org/apache/sling/xss/impl/AntiSamyPolicyAdapter.java:
##########
@@ -222,43 +224,28 @@ public boolean apply(String s) {
     private static Predicate<String> matchesPatternsOrLiterals(List<Pattern> patternList, boolean ignoreCase, List<String> literalList) {
         return new Predicate<String>() {
             public boolean apply(String s) {
-                // check if the string matches to the pattern
-                for (Pattern pattern : patternList) {
-                    if (pattern.matcher(s).matches()) {
-                        return true;
-                    }
-                }
-                // if the pattern does not match it goes through the literals
-                for (String string : literalList) {
-                    s = ignoreCase
-                        ? s.toLowerCase()
-                        : s;
-                    if (string.equals(s)) {
-                        return true;
-                    }
-                }
-                // if it neither matches the patterns nor the literals it returns false
-                return false;
+                // check if the string matches to the pattern or one of the literal
+                s = ignoreCase ? s.toLowerCase() : s;

Review Comment:
   Resolved: [9f0dbc5](https://github.com/apache/sling-org-apache-sling-xss/pull/30/commits/9f0dbc5a30a90a3949c0dcd7f2bc3b2bac41b420)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org