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 sanitice text before inserting the text into an HTML | 10 * This is intended to sanitice text before inserting the text into an HTML |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 * * `'` (apostrophe) when inside a single-quoted attribute value. | 145 * * `'` (apostrophe) when inside a single-quoted attribute value. |
146 * Apostrophe is escaped as `'` instead of `'` since | 146 * Apostrophe is escaped as `'` instead of `'` since |
147 * not all browsers understand `'`. | 147 * not all browsers understand `'`. |
148 * * `/` (slash) is recommended to be escaped because it may be used | 148 * * `/` (slash) is recommended to be escaped because it may be used |
149 * to terminate an element in some HTML dialects. | 149 * to terminate an element in some HTML dialects. |
150 * | 150 * |
151 * Escaping `>` (greater than) isn't necessary, but the result is often | 151 * Escaping `>` (greater than) isn't necessary, but the result is often |
152 * found to be easier to read if greater-than is also escaped whenever | 152 * found to be easier to read if greater-than is also escaped whenever |
153 * less-than is. | 153 * less-than is. |
154 */ | 154 */ |
155 class HtmlEscape extends Converter<String, String> { | 155 class HtmlEscape extends Converter<String, String> |
| 156 implements ChunkedConverter<String, String, String, String> { |
156 | 157 |
157 /** The [HtmlEscapeMode] used by the converter. */ | 158 /** The [HtmlEscapeMode] used by the converter. */ |
158 final HtmlEscapeMode mode; | 159 final HtmlEscapeMode mode; |
159 | 160 |
160 /** | 161 /** |
161 * Create converter that escapes HTML characters. | 162 * Create converter that escapes HTML characters. |
162 * | 163 * |
163 * If [mode] is provided as either [HtmlEscapeMode.ATTRIBUTE] or | 164 * If [mode] is provided as either [HtmlEscapeMode.ATTRIBUTE] or |
164 * [HtmlEscapeMode.ELEMENT], only the corresponding subset of HTML | 165 * [HtmlEscapeMode.ELEMENT], only the corresponding subset of HTML |
165 * characters are escaped. | 166 * characters are escaped. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 if(val == null) { | 223 if(val == null) { |
223 _sink.addSlice(chunk, start, end, isLast); | 224 _sink.addSlice(chunk, start, end, isLast); |
224 } else { | 225 } else { |
225 _sink.add(val); | 226 _sink.add(val); |
226 if (isLast) _sink.close(); | 227 if (isLast) _sink.close(); |
227 } | 228 } |
228 } | 229 } |
229 | 230 |
230 void close() { _sink.close(); } | 231 void close() { _sink.close(); } |
231 } | 232 } |
OLD | NEW |