| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |