| OLD | NEW |
| 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 safe_html; | 7 library safe_html; |
| 8 | 8 |
| 9 import 'package:meta/meta.dart'; | |
| 10 | |
| 11 /** Declares a string that is a well-formed HTML fragment. */ | 9 /** Declares a string that is a well-formed HTML fragment. */ |
| 12 // TODO(sigmund): delete this type now that Element.html is safe by default. | 10 // TODO(sigmund): delete this type now that Element.html is safe by default. |
| 13 class SafeHtml { | 11 class SafeHtml { |
| 14 | 12 |
| 15 /** Underlying html string. */ | 13 /** Underlying html string. */ |
| 16 String _html; | 14 String _html; |
| 17 | 15 |
| 18 /** | 16 /** |
| 19 * dart:html now supports sanitizing elements. You can add any node | 17 * dart:html now supports sanitizing elements. You can add any node |
| 20 * directly in your bindings instead of creating instances of SafeHtml. | 18 * directly in your bindings instead of creating instances of SafeHtml. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 37 | 35 |
| 38 // TODO(sigmund): provide a constructor that takes or creates a Uri and | 36 // TODO(sigmund): provide a constructor that takes or creates a Uri and |
| 39 // validates that it is safe (not a javascript: scheme, for example) | 37 // validates that it is safe (not a javascript: scheme, for example) |
| 40 SafeUri.unsafe(this._uri); | 38 SafeUri.unsafe(this._uri); |
| 41 | 39 |
| 42 String toString() => _uri; | 40 String toString() => _uri; |
| 43 | 41 |
| 44 operator ==(other) => other is SafeUri && _uri == other._uri; | 42 operator ==(other) => other is SafeUri && _uri == other._uri; |
| 45 int get hashCode => _uri.hashCode; | 43 int get hashCode => _uri.hashCode; |
| 46 } | 44 } |
| OLD | NEW |