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.convert; | 5 part of dart.convert; |
6 | 6 |
7 /** | 7 /** |
8 * A `String` converter that converts characters to HTML entities. | 8 * A `String` converter that converts characters to HTML entities. |
9 * | 9 * |
10 * This is intended to sanitize text before inserting the text into an HTML | 10 * This is intended to sanitize text before inserting the text into an HTML |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 * * `'` (apostrophe) when inside a single-quoted attribute value. | 144 * * `'` (apostrophe) when inside a single-quoted attribute value. |
145 * Apostrophe is escaped as `'` instead of `'` since | 145 * Apostrophe is escaped as `'` instead of `'` since |
146 * not all browsers understand `'`. | 146 * not all browsers understand `'`. |
147 * * `/` (slash) is recommended to be escaped because it may be used | 147 * * `/` (slash) is recommended to be escaped because it may be used |
148 * to terminate an element in some HTML dialects. | 148 * to terminate an element in some HTML dialects. |
149 * | 149 * |
150 * Escaping `>` (greater than) isn't necessary, but the result is often | 150 * Escaping `>` (greater than) isn't necessary, but the result is often |
151 * found to be easier to read if greater-than is also escaped whenever | 151 * found to be easier to read if greater-than is also escaped whenever |
152 * less-than is. | 152 * less-than is. |
153 */ | 153 */ |
154 class HtmlEscape extends Converter<String, String> { | 154 class HtmlEscape extends Converter<String, String> |
| 155 implements ChunkedConverter<String, String, String, String> { |
155 /** The [HtmlEscapeMode] used by the converter. */ | 156 /** The [HtmlEscapeMode] used by the converter. */ |
156 final HtmlEscapeMode mode; | 157 final HtmlEscapeMode mode; |
157 | 158 |
158 /** | 159 /** |
159 * Create converter that escapes HTML characters. | 160 * Create converter that escapes HTML characters. |
160 * | 161 * |
161 * If [mode] is provided as either [HtmlEscapeMode.ATTRIBUTE] or | 162 * If [mode] is provided as either [HtmlEscapeMode.ATTRIBUTE] or |
162 * [HtmlEscapeMode.ELEMENT], only the corresponding subset of HTML | 163 * [HtmlEscapeMode.ELEMENT], only the corresponding subset of HTML |
163 * characters are escaped. | 164 * characters are escaped. |
164 * The default is to escape all HTML characters. | 165 * The default is to escape all HTML characters. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 } else { | 235 } else { |
235 _sink.add(val); | 236 _sink.add(val); |
236 if (isLast) _sink.close(); | 237 if (isLast) _sink.close(); |
237 } | 238 } |
238 } | 239 } |
239 | 240 |
240 void close() { | 241 void close() { |
241 _sink.close(); | 242 _sink.close(); |
242 } | 243 } |
243 } | 244 } |
OLD | NEW |