File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\markup\HtmlPolicyBuilder2.java.html

1 package hudson.markup;
2
3 import com.google.common.base.Predicate;
4 import org.owasp.html.HtmlPolicyBuilder;
5
6 import java.util.regex.Pattern;
7
8 /**
9 * {@link HtmlPolicyBuilder} with additional
10 * functions to simplify transcoding policy definition
11 * from OWASP AntiSamy policy files.
12 *
13 * @author Kohsuke Kawaguchi
14 */
15 class HtmlPolicyBuilder2 extends HtmlPolicyBuilder {
16 public void tag(String names, Object... attributes) {
17 String[] tags = names.split(",");
18 for (int i=0; i<attributes.length; i++) {
19 String attName = (String)attributes[i];
20 if (i+1<attributes.length) {
21 Object operand = attributes[i+1];
22 if (operand instanceof Predicate) {
23 Predicate p = (Predicate) operand;
24 allowAttributes(attName).matching(p).onElements(tags);
25 i++;
26 continue;
27 }
28
29 if (operand instanceof Pattern) {
30 Pattern p = (Pattern) operand;
31 allowAttributes(attName).matching(p).onElements(tags);
32 i++;
33 continue;
34 }
35 }
36
37 // operand-less
38 allowAttributes(attName).onElements(tags);
39 }
40 allowElements(tags);
41 }
42 }
43