in src/main/java/org/apache/sling/xss/impl/xml/Attribute.java [48:75]
public Attribute(
@JacksonXmlProperty(localName = "name", isAttribute = true) @NotNull String name,
@JacksonXmlProperty(localName = "regexp-list") List<Regexp> allowedRegexps,
@JacksonXmlProperty(localName = "literal-list") List<Literal> literalList,
@JacksonXmlProperty(localName = "onInvalid", isAttribute = true) String onInvalid,
@JacksonXmlProperty(localName = "description", isAttribute = true) String description) {
this.name = name.toLowerCase(AntiSamyConfigLocale.REGION);
this.description = Optional.ofNullable(description).orElse("");
this.onInvalid =
onInvalid != null && onInvalid.length() > 0 ? onInvalid : AntiSamyActions.REMOVE_ATTRIBUTE_ON_INVALID;
this.regexpList = Optional.ofNullable(allowedRegexps)
.map(Collections::unmodifiableList)
.orElseGet(Collections::emptyList);
this.patternList = this.regexpList.stream()
.map(Regexp::getPattern)
.filter(Objects::nonNull)
.collect(Collectors.toList());
this.literalList = Optional.ofNullable(literalList)
.map(Collections::unmodifiableList)
.orElseGet(Collections::emptyList);
this.literals = this.literalList.stream()
.map(Literal::getValue)
.map(String::toLowerCase)
.distinct()
.collect(Collectors.toList());
}