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

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

Issue 2764943002: Fix some strong mode issues in the core libraries. (Closed)
Patch Set: Rebase Created 3 years, 7 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 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
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> {
156 /** The [HtmlEscapeMode] used by the converter. */ 155 /** The [HtmlEscapeMode] used by the converter. */
157 final HtmlEscapeMode mode; 156 final HtmlEscapeMode mode;
158 157
159 /** 158 /**
160 * Create converter that escapes HTML characters. 159 * Create converter that escapes HTML characters.
161 * 160 *
162 * If [mode] is provided as either [HtmlEscapeMode.ATTRIBUTE] or 161 * If [mode] is provided as either [HtmlEscapeMode.ATTRIBUTE] or
163 * [HtmlEscapeMode.ELEMENT], only the corresponding subset of HTML 162 * [HtmlEscapeMode.ELEMENT], only the corresponding subset of HTML
164 * characters are escaped. 163 * characters are escaped.
165 * The default is to escape all HTML characters. 164 * The default is to escape all HTML characters.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } else { 234 } else {
236 _sink.add(val); 235 _sink.add(val);
237 if (isLast) _sink.close(); 236 if (isLast) _sink.close();
238 } 237 }
239 } 238 }
240 239
241 void close() { 240 void close() {
242 _sink.close(); 241 _sink.close();
243 } 242 }
244 } 243 }
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