Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Unified Diff: tools/dom/src/NodeValidatorBuilder.dart

Issue 1236413002: Make sure NodeValidator uriAttributes aren't passed as attributes (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: And regenerate libraries after formatting Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/html/node_validator_important_if_you_suppress_make_the_bug_critical_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « tests/html/node_validator_important_if_you_suppress_make_the_bug_critical_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698