var mySanitizer = new goog.html.sanitizer.HtmlSanitizer.Builder() .withCustomNetworkRequestUrlPolicy(goog.html.SafeUrl.sanitize)// lose the id? .allowCssStyles() .allowFormTag() .addOriginalTagNames() .withCustomTokenPolicy(goog.functions.identity) // so id= can be used and styles .allowDataAttributes([ "data-id","data-name" ]) //data-* attributes are inert as per HTML5 specs .build();goog.exportSymbol ('toolbox.utils.mySanitizer', mySanitizer) ;
and later I useareYouSureDialog.setSafeHtmlContent(toolbox.utils.mySanitizer.sanitize(htmlAreYouSure));
function kj(a, b) { var c = document.createElement("span"); if (!Pi || !b) return c; try { var d = document.createElement("template"); if ("content"in d) { d.innerHTML = b; var e = d.content } else { var f = document.implementation.createHTMLDocument("x"); e = f.body; f.body.innerHTML = b } var h = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, null, !1) } catch (St) { return c } b = {}; for (e = 0; f = h.nextNode(); ) { e++; var d = a; if (3 == f.nodeType) d = document.createTextNode(f.data); else { var k = gj(f).toUpperCase() , l = !1 , n = !1; if (k in Gi || k in d.g) { var p = "template"; n = !0 } else d.j[k] ? p = k : (p = "span", l = !0); p = document.createElement(p); d.c && l && ej(p, "data-sanitizer-original-tag", k.toLowerCase()); n && ej(p, "data-sanitizer-blacklisted-tag", ""); d = p } if (3 != d.nodeType) { var k = a, l = f, n = d, q; p = l; if (q = (q = Ri.attributes) && q.get ? q.get.apply(p) : p.attributes instanceof NamedNodeMap ? p.attributes : null) for (var r = 0; p = q[r]; r++) if (p.specified) { var t = k; var x = l , N = p , I = N.name; if (Ka(I, "data-sanitizer-")) t = null; else { var Ca = gj(x) , N = N.value , y = { tagName: z(Ca).toLowerCase(), attributeName: z(I).toLowerCase() } , Ji = { Zc: void 0 }; if ("style" == y.attributeName) { var Ki = Ri.style , x = x instanceof HTMLElement && Ki && Ki.get ? Ki.get.apply(x) : x.style instanceof CSSStyleDeclaration ? x.style : null; Ji.Zc = x } Ca = dj(Ca, I); Ca in t.a ? (t = t.a[Ca], t = t(N, y, Ji)) : (I = dj(null, I), I in t.a ? (t = t.a[I], t = t(N, y, Ji)) : t = null) } null === t || ej(n, p.name, t) } b[e] = d; ej(f, "data-sanitizer-elem-num", String(e)) } k = gj(f); Qi && "template" === k.toLowerCase() && !d.hasAttribute("data-sanitizer-blacklisted-tag") && mj(a, f, d); f = hj(f); k = !1; if (null === f) k = !0; else if ("body" == gj(f).toLowerCase() || 11 == f.nodeType) l = hj(f), 11 == f.nodeType && null === l ? k = !0 : "body" == gj(f).toLowerCase() && (l = hj(l), null === hj(l) && (k = !0)); k || !f ? f = c : (f = (k = Element.prototype.getAttribute) && f instanceof Element ? k.call(f, "data-sanitizer-elem-num") || "" : "", f = b[f]); f.content && (f = f.content); ya(d) && 1 == d.nodeType && d.hasAttribute("data-sanitizer-blacklisted-tag") || f.appendChild(d) } return c}
--
---
You received this message because you are subscribed to the Google Groups "Closure Library Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-library-discuss+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ah, sanitize
is an instance property, so exportSymbol
won’t work: you need to use goog.exportProperty
for properties.
goog.exportProperty(goog.html.sanitizer.HtmlSanitizer.prototype, 'sanitize', goog.html.sanitizer.HtmlSanitizer.prototype.sanitize);
--
---
You received this message because you are subscribed to the Google Groups "Closure Library Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-library-discuss+unsubscr...@googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "Closure Library Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/closure-library-discuss/8oGjSUUJkQI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to closure-library-d...@googlegroups.com.
Error was in my code in the way I did my export. Thank you for your help.