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

Side by Side Diff: tools/dom/src/NodeValidatorBuilder.dart

Issue 23793004: Adding an easy way to allow inline style attributes through sanitization (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/html/node_validator_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.dom.html; 5 part of dart.dom.html;
6 6
7 7
8 /** 8 /**
9 * Class which helps construct standard node validation policies. 9 * Class which helps construct standard node validation policies.
10 * 10 *
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 * * OL 103 * * OL
104 * * P 104 * * P
105 * * SPAN 105 * * SPAN
106 * * UL 106 * * UL
107 */ 107 */
108 void allowTextElements() { 108 void allowTextElements() {
109 add(new _SimpleNodeValidator.allowTextElements()); 109 add(new _SimpleNodeValidator.allowTextElements());
110 } 110 }
111 111
112 /** 112 /**
113 * Allow inline styles on elements.
114 *
115 * If [tagName] is not specified then this allows inline styles on all
116 * elements. Otherwise tagName limits the styles to the specified elements.
117 */
118 void allowInlineStyles({String tagName}) {
119 if (tagName == null) {
120 tagName = '*';
121 } else {
122 tagName = tagName.toUpperCase();
123 }
124 add(new _SimpleNodeValidator(null, allowedAttributes: ['$tagName::style']));
125 }
126
127 /**
113 * Allow common safe HTML5 elements and attributes. 128 * Allow common safe HTML5 elements and attributes.
114 * 129 *
115 * This list is based off of the Caja whitelists at: 130 * This list is based off of the Caja whitelists at:
116 * https://code.google.com/p/google-caja/wiki/CajaWhitelists. 131 * https://code.google.com/p/google-caja/wiki/CajaWhitelists.
117 * 132 *
118 * Common things which are not allowed are script elements, style attributes 133 * Common things which are not allowed are script elements, style attributes
119 * and any script handlers. 134 * and any script handlers.
120 */ 135 */
121 void allowHtml5({UriPolicy uriPolicy}) { 136 void allowHtml5({UriPolicy uriPolicy}) {
122 add(new _Html5NodeValidator(uriPolicy: uriPolicy)); 137 add(new _Html5NodeValidator(uriPolicy: uriPolicy));
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 return false; 459 return false;
445 } 460 }
446 461
447 bool allowsAttribute(Element element, String attributeName, String value) { 462 bool allowsAttribute(Element element, String attributeName, String value) {
448 if (attributeName == 'is' || attributeName.startsWith('on')) { 463 if (attributeName == 'is' || attributeName.startsWith('on')) {
449 return false; 464 return false;
450 } 465 }
451 return allowsElement(element); 466 return allowsElement(element);
452 } 467 }
453 } 468 }
OLDNEW
« no previous file with comments | « tests/html/node_validator_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698