Index: tools/dom/src/NodeValidatorBuilder.dart |
diff --git a/tools/dom/src/NodeValidatorBuilder.dart b/tools/dom/src/NodeValidatorBuilder.dart |
index 7ebeb36dd1deb3155d531f19be3b2161c10ffd8f..4a412325bd30ba1bf628e02184d54852f7e7a786 100644 |
--- a/tools/dom/src/NodeValidatorBuilder.dart |
+++ b/tools/dom/src/NodeValidatorBuilder.dart |
@@ -259,17 +259,17 @@ class NodeValidatorBuilder implements NodeValidator { |
} |
class _SimpleNodeValidator implements NodeValidator { |
- final Set<String> allowedElements; |
- final Set<String> allowedAttributes; |
- final Set<String> allowedUriAttributes; |
+ final Set<String> allowedElements = new Set<String>(); |
+ final Set<String> allowedAttributes = new Set<String>(); |
+ final Set<String> allowedUriAttributes = new Set<String>(); |
final UriPolicy uriPolicy; |
factory _SimpleNodeValidator.allowNavigation(UriPolicy uriPolicy) { |
return new _SimpleNodeValidator(uriPolicy, |
- allowedElements: [ |
+ allowedElements: const [ |
'A', |
'FORM'], |
- allowedAttributes: [ |
+ allowedAttributes: const [ |
'A::accesskey', |
'A::coords', |
'A::hreflang', |
@@ -286,7 +286,7 @@ class _SimpleNodeValidator implements NodeValidator { |
'FORM::novalidate', |
'FORM::target', |
], |
- allowedUriAttributes: [ |
+ allowedUriAttributes: const [ |
'A::href', |
'FORM::action', |
]); |
@@ -294,10 +294,10 @@ class _SimpleNodeValidator implements NodeValidator { |
factory _SimpleNodeValidator.allowImages(UriPolicy uriPolicy) { |
return new _SimpleNodeValidator(uriPolicy, |
- allowedElements: [ |
+ allowedElements: const [ |
'IMG' |
], |
- allowedAttributes: [ |
+ allowedAttributes: const [ |
'IMG::align', |
'IMG::alt', |
'IMG::border', |
@@ -309,14 +309,14 @@ class _SimpleNodeValidator implements NodeValidator { |
'IMG::vspace', |
'IMG::width', |
], |
- allowedUriAttributes: [ |
+ allowedUriAttributes: const [ |
'IMG::src', |
]); |
} |
factory _SimpleNodeValidator.allowTextElements() { |
return new _SimpleNodeValidator(null, |
- allowedElements: [ |
+ allowedElements: const [ |
'B', |
'BLOCKQUOTE', |
'BR', |
@@ -344,13 +344,18 @@ class _SimpleNodeValidator implements NodeValidator { |
*/ |
_SimpleNodeValidator(this.uriPolicy, |
{Iterable<String> allowedElements, Iterable<String> allowedAttributes, |
- Iterable<String> allowedUriAttributes}): |
- this.allowedElements = allowedElements != null ? |
- new Set.from(allowedElements) : new Set(), |
- this.allowedAttributes = allowedAttributes != null ? |
- new Set.from(allowedAttributes) : new Set(), |
- this.allowedUriAttributes = allowedUriAttributes != null ? |
- new Set.from(allowedUriAttributes) : new Set(); |
+ Iterable<String> allowedUriAttributes}) { |
+ this.allowedElements.addAll(allowedElements ?? const []); |
+ allowedAttributes = allowedAttributes ?? const []; |
+ allowedUriAttributes = allowedUriAttributes ?? const []; |
+ var legalAttributes = allowedAttributes.where( |
+ (x) => !_Html5NodeValidator._uriAttributes.contains(x)); |
+ var extraUriAttributes = allowedAttributes.where( |
+ (x) => _Html5NodeValidator._uriAttributes.contains(x)); |
+ this.allowedAttributes.addAll(legalAttributes); |
+ this.allowedUriAttributes.addAll(allowedUriAttributes); |
+ this.allowedUriAttributes.addAll(extraUriAttributes); |
+ } |
bool allowsElement(Element element) { |
return allowedElements.contains(element.tagName); |