diff --git a/share/tools/web_config/index.html b/share/tools/web_config/index.html index 02fa7119f..e76aa7ad8 100644 --- a/share/tools/web_config/index.html +++ b/share/tools/web_config/index.html @@ -7,6 +7,7 @@ + diff --git a/share/tools/web_config/js/angular-sanitize.js b/share/tools/web_config/js/angular-sanitize.js new file mode 100644 index 000000000..06f4c229f --- /dev/null +++ b/share/tools/web_config/js/angular-sanitize.js @@ -0,0 +1,556 @@ +/** + * @license AngularJS v1.0.8 + * (c) 2010-2012 Google, Inc. http://angularjs.org + * License: MIT + */ +(function(window, angular, undefined) { +'use strict'; + +/** + * @ngdoc overview + * @name ngSanitize + * @description + * + * The `ngSanitize` module provides functionality to sanitize HTML. + * + * # Installation + * As a separate module, it must be loaded after Angular core is loaded; otherwise, an 'Uncaught Error: + * No module: ngSanitize' runtime error will occur. + * + *
+ * + * + *+ * + * # Usage + * To make sure the module is available to your application, declare it as a dependency of you application + * module. + * + *
+ * angular.module('app', ['ngSanitize']); + *+ */ + +/* + * HTML Parser By Misko Hevery (misko@hevery.com) + * based on: HTML Parser By John Resig (ejohn.org) + * Original code by Erik Arvidsson, Mozilla Public License + * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js + * + * // Use like so: + * htmlParser(htmlString, { + * start: function(tag, attrs, unary) {}, + * end: function(tag) {}, + * chars: function(text) {}, + * comment: function(text) {} + * }); + * + */ + + +/** + * @ngdoc service + * @name ngSanitize.$sanitize + * @function + * + * @description + * The input is sanitized by parsing the html into tokens. All safe tokens (from a whitelist) are + * then serialized back to properly escaped html string. This means that no unsafe input can make + * it into the returned string, however, since our parser is more strict than a typical browser + * parser, it's possible that some obscure input, which would be recognized as valid HTML by a + * browser, won't make it through the sanitizer. + * + * @param {string} html Html input. + * @returns {string} Sanitized html. + * + * @example +
Filter | +Source | +Rendered | +
html filter | +
+ <div ng-bind-html="snippet">+ |
+ + + | +
no filter | +<div ng-bind="snippet"> |
+ + |
unsafe html filter | +<div ng-bind-html-unsafe="snippet"> |
+ + |
an html\nclick here\nsnippet
'); + }); + + it('should escape snippet without any filter', function() { + expect(using('#escaped-html').element('div').html()). + toBe("<p style=\"color:blue\">an html\n" + + "<em onmouseover=\"this.textContent='PWN3D!'\">click here</em>\n" + + "snippet</p>"); + }); + + it('should inline raw snippet if filtered as unsafe', function() { + expect(using('#html-unsafe-filter').element("div").html()). + toBe("an html\n" + + "click here\n" + + "snippet
"); + }); + + it('should update', function() { + input('snippet').enter('new text'); + expect(using('#html-filter').binding('snippet')).toBe('new text'); + expect(using('#escaped-html').element('div').html()).toBe("new <b>text</b>"); + expect(using('#html-unsafe-filter').binding("snippet")).toBe('new text'); + }); +Filter | +Source | +Rendered | +
linky filter | +
+ <div ng-bind-html="snippet | linky">+ |
+ + + | +
no filter | +<div ng-bind="snippet"> |
+ + |