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

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

Issue 1827803002: Make convert library strong-mode compliant. Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix more converters. Created 4 years, 9 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/encoding.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 ChunkedConverter<String, String, String, String> {
156 156
157 /** The [HtmlEscapeMode] used by the converter. */ 157 /** The [HtmlEscapeMode] used by the converter. */
158 final HtmlEscapeMode mode; 158 final HtmlEscapeMode mode;
159 159
160 /** 160 /**
161 * Create converter that escapes HTML characters. 161 * Create converter that escapes HTML characters.
162 * 162 *
163 * If [mode] is provided as either [HtmlEscapeMode.ATTRIBUTE] or 163 * If [mode] is provided as either [HtmlEscapeMode.ATTRIBUTE] or
164 * [HtmlEscapeMode.ELEMENT], only the corresponding subset of HTML 164 * [HtmlEscapeMode.ELEMENT], only the corresponding subset of HTML
165 * characters are escaped. 165 * characters are escaped.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 if(val == null) { 222 if(val == null) {
223 _sink.addSlice(chunk, start, end, isLast); 223 _sink.addSlice(chunk, start, end, isLast);
224 } else { 224 } else {
225 _sink.add(val); 225 _sink.add(val);
226 if (isLast) _sink.close(); 226 if (isLast) _sink.close();
227 } 227 }
228 } 228 }
229 229
230 void close() => _sink.close(); 230 void close() => _sink.close();
231 } 231 }
OLDNEW
« no previous file with comments | « sdk/lib/convert/encoding.dart ('k') | sdk/lib/convert/json.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698