diff --git a/IPython/html/static/base/js/security.js b/IPython/html/static/base/js/security.js index 648cf03..183b4c5 100644 --- a/IPython/html/static/base/js/security.js +++ b/IPython/html/static/base/js/security.js @@ -14,43 +14,43 @@ IPython.security = (function (IPython) { "use strict"; var utils = IPython.utils; - + + var noop = function (x) { return x; }; + + var sanitize = function (html, log) { + // sanitize HTML + // returns a struct of + // { + // src: original_html, + // sanitized: the_sanitized_html, + // safe: bool // false if the sanitizer made any changes + // } + var result = { + src : html, + safe : true + }; + var record_messages = function (msg, opts) { + console.log("HTML Sanitizer", msg, opts); + result.safe = false; + }; + result.sanitized = window.html_sanitize(html, noop, noop, record_messages); + return result; + }; + + var sanitize_html = function (html) { + // shorthand for str-to-str conversion, dropping the struct + return sanitize(html).sanitized; + }; + var is_safe = function (html) { - // Is the html string safe against JavaScript based attacks. This - // detects 1) black listed tags, 2) blacklisted attributes, 3) all - // event attributes (onhover, onclick, etc.). - var black_tags = ['script', 'style', 'meta', 'iframe', 'embed']; - var black_attrs = ['style']; - var wrapped_html = '