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

Side by Side Diff: sdk/lib/convert/html_escape.dart

Issue 2035473003: Avoid runtime type errors in checked mode for ChunkedConverters. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « sdk/lib/convert/converter.dart ('k') | sdk/lib/convert/json.dart » ('j') | 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.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
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
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 }
OLDNEW
« no previous file with comments | « sdk/lib/convert/converter.dart ('k') | sdk/lib/convert/json.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698