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

Side by Side Diff: lib/safe_html.dart

Issue 22962005: Merge pull request #581 from kevmoo/polymer (Closed) Base URL: https://github.com/dart-lang/web-ui.git@polymer
Patch Set: Created 7 years, 4 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 | « lib/polymer_element.dart ('k') | lib/scoped_css.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // TODO(sigmund): move this library to a shared package? or make part of 5 // TODO(sigmund): move this library to a shared package? or make part of
6 // dart:html? 6 // dart:html?
7 library polymer.safe_html; 7 library polymer.safe_html;
8 8
9 /** Declares a string that is a well-formed HTML fragment. */ 9 /** Declares a string that is a well-formed HTML fragment. */
10 class SafeHtml { 10 class SafeHtml {
11 11
12 /** Underlying html string. */ 12 /** Underlying html string. */
13 String _html; 13 final String _html;
14 14
15 // TODO(sigmund): provide a constructor that does html validation 15 // TODO(sigmund): provide a constructor that does html validation
16 SafeHtml.unsafe(this._html); 16 SafeHtml.unsafe(this._html);
17 17
18 String toString() => _html; 18 String toString() => _html;
19 19
20 operator ==(other) => other is SafeHtml && _html == other._html; 20 operator ==(other) => other is SafeHtml && _html == other._html;
21 int get hashCode => _html.hashCode; 21 int get hashCode => _html.hashCode;
22 } 22 }
23 23
24 /** 24 /**
25 * Declares a string that is safe to use in a Uri attribute, such as `<a href=`, 25 * Declares a string that is safe to use in a Uri attribute, such as `<a href=`,
26 * to avoid cross-site scripting (XSS) attacks. 26 * to avoid cross-site scripting (XSS) attacks.
27 */ 27 */
28 class SafeUri { 28 class SafeUri {
29 String _uri; 29 final String _uri;
30 30
31 // TODO(sigmund): provide a constructor that takes or creates a Uri and 31 // TODO(sigmund): provide a constructor that takes or creates a Uri and
32 // validates that it is safe (not a javascript: scheme, for example) 32 // validates that it is safe (not a javascript: scheme, for example)
33 SafeUri.unsafe(this._uri); 33 SafeUri.unsafe(this._uri);
34 34
35 String toString() => _uri; 35 String toString() => _uri;
36 36
37 operator ==(other) => other is SafeUri && _uri == other._uri; 37 operator ==(other) => other is SafeUri && _uri == other._uri;
38 int get hashCode => _uri.hashCode; 38 int get hashCode => _uri.hashCode;
39 } 39 }
OLDNEW
« no previous file with comments | « lib/polymer_element.dart ('k') | lib/scoped_css.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698