purify.cjs.js 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453
  1. /*! @license DOMPurify 2.3.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.3.6/LICENSE */
  2. 'use strict';
  3. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  4. var hasOwnProperty = Object.hasOwnProperty,
  5. setPrototypeOf = Object.setPrototypeOf,
  6. isFrozen = Object.isFrozen,
  7. getPrototypeOf = Object.getPrototypeOf,
  8. getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  9. var freeze = Object.freeze,
  10. seal = Object.seal,
  11. create = Object.create; // eslint-disable-line import/no-mutable-exports
  12. var _ref = typeof Reflect !== 'undefined' && Reflect,
  13. apply = _ref.apply,
  14. construct = _ref.construct;
  15. if (!apply) {
  16. apply = function apply(fun, thisValue, args) {
  17. return fun.apply(thisValue, args);
  18. };
  19. }
  20. if (!freeze) {
  21. freeze = function freeze(x) {
  22. return x;
  23. };
  24. }
  25. if (!seal) {
  26. seal = function seal(x) {
  27. return x;
  28. };
  29. }
  30. if (!construct) {
  31. construct = function construct(Func, args) {
  32. return new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))();
  33. };
  34. }
  35. var arrayForEach = unapply(Array.prototype.forEach);
  36. var arrayPop = unapply(Array.prototype.pop);
  37. var arrayPush = unapply(Array.prototype.push);
  38. var stringToLowerCase = unapply(String.prototype.toLowerCase);
  39. var stringMatch = unapply(String.prototype.match);
  40. var stringReplace = unapply(String.prototype.replace);
  41. var stringIndexOf = unapply(String.prototype.indexOf);
  42. var stringTrim = unapply(String.prototype.trim);
  43. var regExpTest = unapply(RegExp.prototype.test);
  44. var typeErrorCreate = unconstruct(TypeError);
  45. function unapply(func) {
  46. return function (thisArg) {
  47. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  48. args[_key - 1] = arguments[_key];
  49. }
  50. return apply(func, thisArg, args);
  51. };
  52. }
  53. function unconstruct(func) {
  54. return function () {
  55. for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  56. args[_key2] = arguments[_key2];
  57. }
  58. return construct(func, args);
  59. };
  60. }
  61. /* Add properties to a lookup table */
  62. function addToSet(set, array) {
  63. if (setPrototypeOf) {
  64. // Make 'in' and truthy checks like Boolean(set.constructor)
  65. // independent of any properties defined on Object.prototype.
  66. // Prevent prototype setters from intercepting set as a this value.
  67. setPrototypeOf(set, null);
  68. }
  69. var l = array.length;
  70. while (l--) {
  71. var element = array[l];
  72. if (typeof element === 'string') {
  73. var lcElement = stringToLowerCase(element);
  74. if (lcElement !== element) {
  75. // Config presets (e.g. tags.js, attrs.js) are immutable.
  76. if (!isFrozen(array)) {
  77. array[l] = lcElement;
  78. }
  79. element = lcElement;
  80. }
  81. }
  82. set[element] = true;
  83. }
  84. return set;
  85. }
  86. /* Shallow clone an object */
  87. function clone(object) {
  88. var newObject = create(null);
  89. var property = void 0;
  90. for (property in object) {
  91. if (apply(hasOwnProperty, object, [property])) {
  92. newObject[property] = object[property];
  93. }
  94. }
  95. return newObject;
  96. }
  97. /* IE10 doesn't support __lookupGetter__ so lets'
  98. * simulate it. It also automatically checks
  99. * if the prop is function or getter and behaves
  100. * accordingly. */
  101. function lookupGetter(object, prop) {
  102. while (object !== null) {
  103. var desc = getOwnPropertyDescriptor(object, prop);
  104. if (desc) {
  105. if (desc.get) {
  106. return unapply(desc.get);
  107. }
  108. if (typeof desc.value === 'function') {
  109. return unapply(desc.value);
  110. }
  111. }
  112. object = getPrototypeOf(object);
  113. }
  114. function fallbackValue(element) {
  115. console.warn('fallback value for', element);
  116. return null;
  117. }
  118. return fallbackValue;
  119. }
  120. var html = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
  121. // SVG
  122. var svg = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
  123. var svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
  124. // List of SVG elements that are disallowed by default.
  125. // We still need to know them so that we can do namespace
  126. // checks properly in case one wants to add them to
  127. // allow-list.
  128. var svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
  129. var mathMl = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover']);
  130. // Similarly to SVG, we want to know all MathML elements,
  131. // even those that we disallow by default.
  132. var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
  133. var text = freeze(['#text']);
  134. var html$1 = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']);
  135. var svg$1 = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
  136. var mathMl$1 = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
  137. var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
  138. // eslint-disable-next-line unicorn/better-regex
  139. var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
  140. var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm);
  141. var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
  142. var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
  143. var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
  144. );
  145. var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
  146. var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
  147. );
  148. var DOCTYPE_NAME = seal(/^html$/i);
  149. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  150. function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  151. var getGlobal = function getGlobal() {
  152. return typeof window === 'undefined' ? null : window;
  153. };
  154. /**
  155. * Creates a no-op policy for internal use only.
  156. * Don't export this function outside this module!
  157. * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
  158. * @param {Document} document The document object (to determine policy name suffix)
  159. * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
  160. * are not supported).
  161. */
  162. var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) {
  163. if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
  164. return null;
  165. }
  166. // Allow the callers to control the unique policy name
  167. // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
  168. // Policy creation with duplicate names throws in Trusted Types.
  169. var suffix = null;
  170. var ATTR_NAME = 'data-tt-policy-suffix';
  171. if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) {
  172. suffix = document.currentScript.getAttribute(ATTR_NAME);
  173. }
  174. var policyName = 'dompurify' + (suffix ? '#' + suffix : '');
  175. try {
  176. return trustedTypes.createPolicy(policyName, {
  177. createHTML: function createHTML(html$$1) {
  178. return html$$1;
  179. }
  180. });
  181. } catch (_) {
  182. // Policy creation failed (most likely another DOMPurify script has
  183. // already run). Skip creating the policy, as this will only cause errors
  184. // if TT are enforced.
  185. console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
  186. return null;
  187. }
  188. };
  189. function createDOMPurify() {
  190. var window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
  191. var DOMPurify = function DOMPurify(root) {
  192. return createDOMPurify(root);
  193. };
  194. /**
  195. * Version label, exposed for easier checks
  196. * if DOMPurify is up to date or not
  197. */
  198. DOMPurify.version = '2.3.6';
  199. /**
  200. * Array of elements that DOMPurify removed during sanitation.
  201. * Empty if nothing was removed.
  202. */
  203. DOMPurify.removed = [];
  204. if (!window || !window.document || window.document.nodeType !== 9) {
  205. // Not running in a browser, provide a factory function
  206. // so that you can pass your own Window
  207. DOMPurify.isSupported = false;
  208. return DOMPurify;
  209. }
  210. var originalDocument = window.document;
  211. var document = window.document;
  212. var DocumentFragment = window.DocumentFragment,
  213. HTMLTemplateElement = window.HTMLTemplateElement,
  214. Node = window.Node,
  215. Element = window.Element,
  216. NodeFilter = window.NodeFilter,
  217. _window$NamedNodeMap = window.NamedNodeMap,
  218. NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap,
  219. HTMLFormElement = window.HTMLFormElement,
  220. DOMParser = window.DOMParser,
  221. trustedTypes = window.trustedTypes;
  222. var ElementPrototype = Element.prototype;
  223. var cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
  224. var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
  225. var getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
  226. var getParentNode = lookupGetter(ElementPrototype, 'parentNode');
  227. // As per issue #47, the web-components registry is inherited by a
  228. // new document created via createHTMLDocument. As per the spec
  229. // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
  230. // a new empty registry is used when creating a template contents owner
  231. // document, so we use that as our parent document to ensure nothing
  232. // is inherited.
  233. if (typeof HTMLTemplateElement === 'function') {
  234. var template = document.createElement('template');
  235. if (template.content && template.content.ownerDocument) {
  236. document = template.content.ownerDocument;
  237. }
  238. }
  239. var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument);
  240. var emptyHTML = trustedTypesPolicy ? trustedTypesPolicy.createHTML('') : '';
  241. var _document = document,
  242. implementation = _document.implementation,
  243. createNodeIterator = _document.createNodeIterator,
  244. createDocumentFragment = _document.createDocumentFragment,
  245. getElementsByTagName = _document.getElementsByTagName;
  246. var importNode = originalDocument.importNode;
  247. var documentMode = {};
  248. try {
  249. documentMode = clone(document).documentMode ? document.documentMode : {};
  250. } catch (_) {}
  251. var hooks = {};
  252. /**
  253. * Expose whether this browser supports running the full DOMPurify.
  254. */
  255. DOMPurify.isSupported = typeof getParentNode === 'function' && implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9;
  256. var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR,
  257. ERB_EXPR$$1 = ERB_EXPR,
  258. DATA_ATTR$$1 = DATA_ATTR,
  259. ARIA_ATTR$$1 = ARIA_ATTR,
  260. IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA,
  261. ATTR_WHITESPACE$$1 = ATTR_WHITESPACE;
  262. var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI;
  263. /**
  264. * We consider the elements and attributes below to be safe. Ideally
  265. * don't add any new ones but feel free to remove unwanted ones.
  266. */
  267. /* allowed element names */
  268. var ALLOWED_TAGS = null;
  269. var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(html), _toConsumableArray$1(svg), _toConsumableArray$1(svgFilters), _toConsumableArray$1(mathMl), _toConsumableArray$1(text)));
  270. /* Allowed attribute names */
  271. var ALLOWED_ATTR = null;
  272. var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray$1(html$1), _toConsumableArray$1(svg$1), _toConsumableArray$1(mathMl$1), _toConsumableArray$1(xml)));
  273. /*
  274. * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
  275. * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
  276. * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
  277. * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
  278. */
  279. var CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {
  280. tagNameCheck: {
  281. writable: true,
  282. configurable: false,
  283. enumerable: true,
  284. value: null
  285. },
  286. attributeNameCheck: {
  287. writable: true,
  288. configurable: false,
  289. enumerable: true,
  290. value: null
  291. },
  292. allowCustomizedBuiltInElements: {
  293. writable: true,
  294. configurable: false,
  295. enumerable: true,
  296. value: false
  297. }
  298. }));
  299. /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
  300. var FORBID_TAGS = null;
  301. /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
  302. var FORBID_ATTR = null;
  303. /* Decide if ARIA attributes are okay */
  304. var ALLOW_ARIA_ATTR = true;
  305. /* Decide if custom data attributes are okay */
  306. var ALLOW_DATA_ATTR = true;
  307. /* Decide if unknown protocols are okay */
  308. var ALLOW_UNKNOWN_PROTOCOLS = false;
  309. /* Output should be safe for common template engines.
  310. * This means, DOMPurify removes data attributes, mustaches and ERB
  311. */
  312. var SAFE_FOR_TEMPLATES = false;
  313. /* Decide if document with <html>... should be returned */
  314. var WHOLE_DOCUMENT = false;
  315. /* Track whether config is already set on this instance of DOMPurify. */
  316. var SET_CONFIG = false;
  317. /* Decide if all elements (e.g. style, script) must be children of
  318. * document.body. By default, browsers might move them to document.head */
  319. var FORCE_BODY = false;
  320. /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
  321. * string (or a TrustedHTML object if Trusted Types are supported).
  322. * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
  323. */
  324. var RETURN_DOM = false;
  325. /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
  326. * string (or a TrustedHTML object if Trusted Types are supported) */
  327. var RETURN_DOM_FRAGMENT = false;
  328. /* Try to return a Trusted Type object instead of a string, return a string in
  329. * case Trusted Types are not supported */
  330. var RETURN_TRUSTED_TYPE = false;
  331. /* Output should be free from DOM clobbering attacks? */
  332. var SANITIZE_DOM = true;
  333. /* Keep element content when removing element? */
  334. var KEEP_CONTENT = true;
  335. /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
  336. * of importing it into a new Document and returning a sanitized copy */
  337. var IN_PLACE = false;
  338. /* Allow usage of profiles like html, svg and mathMl */
  339. var USE_PROFILES = {};
  340. /* Tags to ignore content of when KEEP_CONTENT is true */
  341. var FORBID_CONTENTS = null;
  342. var DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
  343. /* Tags that are safe for data: URIs */
  344. var DATA_URI_TAGS = null;
  345. var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
  346. /* Attributes safe for values like "javascript:" */
  347. var URI_SAFE_ATTRIBUTES = null;
  348. var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
  349. var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
  350. var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
  351. var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
  352. /* Document namespace */
  353. var NAMESPACE = HTML_NAMESPACE;
  354. var IS_EMPTY_INPUT = false;
  355. /* Parsing of strict XHTML documents */
  356. var PARSER_MEDIA_TYPE = void 0;
  357. var SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
  358. var DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
  359. var transformCaseFunc = void 0;
  360. /* Keep a reference to config to pass to hooks */
  361. var CONFIG = null;
  362. /* Ideally, do not touch anything below this line */
  363. /* ______________________________________________ */
  364. var formElement = document.createElement('form');
  365. var isRegexOrFunction = function isRegexOrFunction(testValue) {
  366. return testValue instanceof RegExp || testValue instanceof Function;
  367. };
  368. /**
  369. * _parseConfig
  370. *
  371. * @param {Object} cfg optional config literal
  372. */
  373. // eslint-disable-next-line complexity
  374. var _parseConfig = function _parseConfig(cfg) {
  375. if (CONFIG && CONFIG === cfg) {
  376. return;
  377. }
  378. /* Shield configuration object from tampering */
  379. if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') {
  380. cfg = {};
  381. }
  382. /* Shield configuration object from prototype pollution */
  383. cfg = clone(cfg);
  384. /* Set configuration parameters */
  385. ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS;
  386. ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR;
  387. URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR) : DEFAULT_URI_SAFE_ATTRIBUTES;
  388. DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS) : DEFAULT_DATA_URI_TAGS;
  389. FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS) : DEFAULT_FORBID_CONTENTS;
  390. FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS) : {};
  391. FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR) : {};
  392. USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
  393. ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
  394. ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
  395. ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
  396. SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
  397. WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
  398. RETURN_DOM = cfg.RETURN_DOM || false; // Default false
  399. RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
  400. RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
  401. FORCE_BODY = cfg.FORCE_BODY || false; // Default false
  402. SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
  403. KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
  404. IN_PLACE = cfg.IN_PLACE || false; // Default false
  405. IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1;
  406. NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
  407. if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
  408. CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
  409. }
  410. if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
  411. CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
  412. }
  413. if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
  414. CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
  415. }
  416. PARSER_MEDIA_TYPE =
  417. // eslint-disable-next-line unicorn/prefer-includes
  418. SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE;
  419. // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
  420. transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? function (x) {
  421. return x;
  422. } : stringToLowerCase;
  423. if (SAFE_FOR_TEMPLATES) {
  424. ALLOW_DATA_ATTR = false;
  425. }
  426. if (RETURN_DOM_FRAGMENT) {
  427. RETURN_DOM = true;
  428. }
  429. /* Parse profile info */
  430. if (USE_PROFILES) {
  431. ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(text)));
  432. ALLOWED_ATTR = [];
  433. if (USE_PROFILES.html === true) {
  434. addToSet(ALLOWED_TAGS, html);
  435. addToSet(ALLOWED_ATTR, html$1);
  436. }
  437. if (USE_PROFILES.svg === true) {
  438. addToSet(ALLOWED_TAGS, svg);
  439. addToSet(ALLOWED_ATTR, svg$1);
  440. addToSet(ALLOWED_ATTR, xml);
  441. }
  442. if (USE_PROFILES.svgFilters === true) {
  443. addToSet(ALLOWED_TAGS, svgFilters);
  444. addToSet(ALLOWED_ATTR, svg$1);
  445. addToSet(ALLOWED_ATTR, xml);
  446. }
  447. if (USE_PROFILES.mathMl === true) {
  448. addToSet(ALLOWED_TAGS, mathMl);
  449. addToSet(ALLOWED_ATTR, mathMl$1);
  450. addToSet(ALLOWED_ATTR, xml);
  451. }
  452. }
  453. /* Merge configuration parameters */
  454. if (cfg.ADD_TAGS) {
  455. if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
  456. ALLOWED_TAGS = clone(ALLOWED_TAGS);
  457. }
  458. addToSet(ALLOWED_TAGS, cfg.ADD_TAGS);
  459. }
  460. if (cfg.ADD_ATTR) {
  461. if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
  462. ALLOWED_ATTR = clone(ALLOWED_ATTR);
  463. }
  464. addToSet(ALLOWED_ATTR, cfg.ADD_ATTR);
  465. }
  466. if (cfg.ADD_URI_SAFE_ATTR) {
  467. addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR);
  468. }
  469. if (cfg.FORBID_CONTENTS) {
  470. if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
  471. FORBID_CONTENTS = clone(FORBID_CONTENTS);
  472. }
  473. addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS);
  474. }
  475. /* Add #text in case KEEP_CONTENT is set to true */
  476. if (KEEP_CONTENT) {
  477. ALLOWED_TAGS['#text'] = true;
  478. }
  479. /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
  480. if (WHOLE_DOCUMENT) {
  481. addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
  482. }
  483. /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
  484. if (ALLOWED_TAGS.table) {
  485. addToSet(ALLOWED_TAGS, ['tbody']);
  486. delete FORBID_TAGS.tbody;
  487. }
  488. // Prevent further manipulation of configuration.
  489. // Not available in IE8, Safari 5, etc.
  490. if (freeze) {
  491. freeze(cfg);
  492. }
  493. CONFIG = cfg;
  494. };
  495. var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
  496. var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']);
  497. /* Keep track of all possible SVG and MathML tags
  498. * so that we can perform the namespace checks
  499. * correctly. */
  500. var ALL_SVG_TAGS = addToSet({}, svg);
  501. addToSet(ALL_SVG_TAGS, svgFilters);
  502. addToSet(ALL_SVG_TAGS, svgDisallowed);
  503. var ALL_MATHML_TAGS = addToSet({}, mathMl);
  504. addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
  505. /**
  506. *
  507. *
  508. * @param {Element} element a DOM element whose namespace is being checked
  509. * @returns {boolean} Return false if the element has a
  510. * namespace that a spec-compliant parser would never
  511. * return. Return true otherwise.
  512. */
  513. var _checkValidNamespace = function _checkValidNamespace(element) {
  514. var parent = getParentNode(element);
  515. // In JSDOM, if we're inside shadow DOM, then parentNode
  516. // can be null. We just simulate parent in this case.
  517. if (!parent || !parent.tagName) {
  518. parent = {
  519. namespaceURI: HTML_NAMESPACE,
  520. tagName: 'template'
  521. };
  522. }
  523. var tagName = stringToLowerCase(element.tagName);
  524. var parentTagName = stringToLowerCase(parent.tagName);
  525. if (element.namespaceURI === SVG_NAMESPACE) {
  526. // The only way to switch from HTML namespace to SVG
  527. // is via <svg>. If it happens via any other tag, then
  528. // it should be killed.
  529. if (parent.namespaceURI === HTML_NAMESPACE) {
  530. return tagName === 'svg';
  531. }
  532. // The only way to switch from MathML to SVG is via
  533. // svg if parent is either <annotation-xml> or MathML
  534. // text integration points.
  535. if (parent.namespaceURI === MATHML_NAMESPACE) {
  536. return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
  537. }
  538. // We only allow elements that are defined in SVG
  539. // spec. All others are disallowed in SVG namespace.
  540. return Boolean(ALL_SVG_TAGS[tagName]);
  541. }
  542. if (element.namespaceURI === MATHML_NAMESPACE) {
  543. // The only way to switch from HTML namespace to MathML
  544. // is via <math>. If it happens via any other tag, then
  545. // it should be killed.
  546. if (parent.namespaceURI === HTML_NAMESPACE) {
  547. return tagName === 'math';
  548. }
  549. // The only way to switch from SVG to MathML is via
  550. // <math> and HTML integration points
  551. if (parent.namespaceURI === SVG_NAMESPACE) {
  552. return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
  553. }
  554. // We only allow elements that are defined in MathML
  555. // spec. All others are disallowed in MathML namespace.
  556. return Boolean(ALL_MATHML_TAGS[tagName]);
  557. }
  558. if (element.namespaceURI === HTML_NAMESPACE) {
  559. // The only way to switch from SVG to HTML is via
  560. // HTML integration points, and from MathML to HTML
  561. // is via MathML text integration points
  562. if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
  563. return false;
  564. }
  565. if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
  566. return false;
  567. }
  568. // Certain elements are allowed in both SVG and HTML
  569. // namespace. We need to specify them explicitly
  570. // so that they don't get erronously deleted from
  571. // HTML namespace.
  572. var commonSvgAndHTMLElements = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
  573. // We disallow tags that are specific for MathML
  574. // or SVG and should never appear in HTML namespace
  575. return !ALL_MATHML_TAGS[tagName] && (commonSvgAndHTMLElements[tagName] || !ALL_SVG_TAGS[tagName]);
  576. }
  577. // The code should never reach this place (this means
  578. // that the element somehow got namespace that is not
  579. // HTML, SVG or MathML). Return false just in case.
  580. return false;
  581. };
  582. /**
  583. * _forceRemove
  584. *
  585. * @param {Node} node a DOM node
  586. */
  587. var _forceRemove = function _forceRemove(node) {
  588. arrayPush(DOMPurify.removed, { element: node });
  589. try {
  590. // eslint-disable-next-line unicorn/prefer-dom-node-remove
  591. node.parentNode.removeChild(node);
  592. } catch (_) {
  593. try {
  594. node.outerHTML = emptyHTML;
  595. } catch (_) {
  596. node.remove();
  597. }
  598. }
  599. };
  600. /**
  601. * _removeAttribute
  602. *
  603. * @param {String} name an Attribute name
  604. * @param {Node} node a DOM node
  605. */
  606. var _removeAttribute = function _removeAttribute(name, node) {
  607. try {
  608. arrayPush(DOMPurify.removed, {
  609. attribute: node.getAttributeNode(name),
  610. from: node
  611. });
  612. } catch (_) {
  613. arrayPush(DOMPurify.removed, {
  614. attribute: null,
  615. from: node
  616. });
  617. }
  618. node.removeAttribute(name);
  619. // We void attribute values for unremovable "is"" attributes
  620. if (name === 'is' && !ALLOWED_ATTR[name]) {
  621. if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
  622. try {
  623. _forceRemove(node);
  624. } catch (_) {}
  625. } else {
  626. try {
  627. node.setAttribute(name, '');
  628. } catch (_) {}
  629. }
  630. }
  631. };
  632. /**
  633. * _initDocument
  634. *
  635. * @param {String} dirty a string of dirty markup
  636. * @return {Document} a DOM, filled with the dirty markup
  637. */
  638. var _initDocument = function _initDocument(dirty) {
  639. /* Create a HTML document */
  640. var doc = void 0;
  641. var leadingWhitespace = void 0;
  642. if (FORCE_BODY) {
  643. dirty = '<remove></remove>' + dirty;
  644. } else {
  645. /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
  646. var matches = stringMatch(dirty, /^[\r\n\t ]+/);
  647. leadingWhitespace = matches && matches[0];
  648. }
  649. if (PARSER_MEDIA_TYPE === 'application/xhtml+xml') {
  650. // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
  651. dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
  652. }
  653. var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
  654. /*
  655. * Use the DOMParser API by default, fallback later if needs be
  656. * DOMParser not work for svg when has multiple root element.
  657. */
  658. if (NAMESPACE === HTML_NAMESPACE) {
  659. try {
  660. doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
  661. } catch (_) {}
  662. }
  663. /* Use createHTMLDocument in case DOMParser is not available */
  664. if (!doc || !doc.documentElement) {
  665. doc = implementation.createDocument(NAMESPACE, 'template', null);
  666. try {
  667. doc.documentElement.innerHTML = IS_EMPTY_INPUT ? '' : dirtyPayload;
  668. } catch (_) {
  669. // Syntax error if dirtyPayload is invalid xml
  670. }
  671. }
  672. var body = doc.body || doc.documentElement;
  673. if (dirty && leadingWhitespace) {
  674. body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
  675. }
  676. /* Work on whole document or just its body */
  677. if (NAMESPACE === HTML_NAMESPACE) {
  678. return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
  679. }
  680. return WHOLE_DOCUMENT ? doc.documentElement : body;
  681. };
  682. /**
  683. * _createIterator
  684. *
  685. * @param {Document} root document/fragment to create iterator for
  686. * @return {Iterator} iterator instance
  687. */
  688. var _createIterator = function _createIterator(root) {
  689. return createNodeIterator.call(root.ownerDocument || root, root,
  690. // eslint-disable-next-line no-bitwise
  691. NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
  692. };
  693. /**
  694. * _isClobbered
  695. *
  696. * @param {Node} elm element to check for clobbering attacks
  697. * @return {Boolean} true if clobbered, false if safe
  698. */
  699. var _isClobbered = function _isClobbered(elm) {
  700. return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function');
  701. };
  702. /**
  703. * _isNode
  704. *
  705. * @param {Node} obj object to check whether it's a DOM node
  706. * @return {Boolean} true is object is a DOM node
  707. */
  708. var _isNode = function _isNode(object) {
  709. return (typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? object instanceof Node : object && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
  710. };
  711. /**
  712. * _executeHook
  713. * Execute user configurable hooks
  714. *
  715. * @param {String} entryPoint Name of the hook's entry point
  716. * @param {Node} currentNode node to work on with the hook
  717. * @param {Object} data additional hook parameters
  718. */
  719. var _executeHook = function _executeHook(entryPoint, currentNode, data) {
  720. if (!hooks[entryPoint]) {
  721. return;
  722. }
  723. arrayForEach(hooks[entryPoint], function (hook) {
  724. hook.call(DOMPurify, currentNode, data, CONFIG);
  725. });
  726. };
  727. /**
  728. * _sanitizeElements
  729. *
  730. * @protect nodeName
  731. * @protect textContent
  732. * @protect removeChild
  733. *
  734. * @param {Node} currentNode to check for permission to exist
  735. * @return {Boolean} true if node was killed, false if left alive
  736. */
  737. var _sanitizeElements = function _sanitizeElements(currentNode) {
  738. var content = void 0;
  739. /* Execute a hook if present */
  740. _executeHook('beforeSanitizeElements', currentNode, null);
  741. /* Check if element is clobbered or can clobber */
  742. if (_isClobbered(currentNode)) {
  743. _forceRemove(currentNode);
  744. return true;
  745. }
  746. /* Check if tagname contains Unicode */
  747. if (stringMatch(currentNode.nodeName, /[\u0080-\uFFFF]/)) {
  748. _forceRemove(currentNode);
  749. return true;
  750. }
  751. /* Now let's check the element's type and name */
  752. var tagName = transformCaseFunc(currentNode.nodeName);
  753. /* Execute a hook if present */
  754. _executeHook('uponSanitizeElement', currentNode, {
  755. tagName: tagName,
  756. allowedTags: ALLOWED_TAGS
  757. });
  758. /* Detect mXSS attempts abusing namespace confusion */
  759. if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
  760. _forceRemove(currentNode);
  761. return true;
  762. }
  763. /* Mitigate a problem with templates inside select */
  764. if (tagName === 'select' && regExpTest(/<template/i, currentNode.innerHTML)) {
  765. _forceRemove(currentNode);
  766. return true;
  767. }
  768. /* Remove element if anything forbids its presence */
  769. if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
  770. /* Check if we have a custom element to handle */
  771. if (!FORBID_TAGS[tagName] && _basicCustomElementTest(tagName)) {
  772. if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
  773. if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) return false;
  774. }
  775. /* Keep content except for bad-listed elements */
  776. if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
  777. var parentNode = getParentNode(currentNode) || currentNode.parentNode;
  778. var childNodes = getChildNodes(currentNode) || currentNode.childNodes;
  779. if (childNodes && parentNode) {
  780. var childCount = childNodes.length;
  781. for (var i = childCount - 1; i >= 0; --i) {
  782. parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
  783. }
  784. }
  785. }
  786. _forceRemove(currentNode);
  787. return true;
  788. }
  789. /* Check whether element has a valid namespace */
  790. if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
  791. _forceRemove(currentNode);
  792. return true;
  793. }
  794. if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
  795. _forceRemove(currentNode);
  796. return true;
  797. }
  798. /* Sanitize element content to be template-safe */
  799. if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
  800. /* Get the element's text content */
  801. content = currentNode.textContent;
  802. content = stringReplace(content, MUSTACHE_EXPR$$1, ' ');
  803. content = stringReplace(content, ERB_EXPR$$1, ' ');
  804. if (currentNode.textContent !== content) {
  805. arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
  806. currentNode.textContent = content;
  807. }
  808. }
  809. /* Execute a hook if present */
  810. _executeHook('afterSanitizeElements', currentNode, null);
  811. return false;
  812. };
  813. /**
  814. * _isValidAttribute
  815. *
  816. * @param {string} lcTag Lowercase tag name of containing element.
  817. * @param {string} lcName Lowercase attribute name.
  818. * @param {string} value Attribute value.
  819. * @return {Boolean} Returns true if `value` is valid, otherwise false.
  820. */
  821. // eslint-disable-next-line complexity
  822. var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
  823. /* Make sure attribute cannot clobber */
  824. if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
  825. return false;
  826. }
  827. /* Allow valid data-* attributes: At least one character after "-"
  828. (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
  829. XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
  830. We don't need to check the value; it's always URI safe. */
  831. if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$$1, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
  832. if (
  833. // First condition does a very basic check if a) it's basically a valid custom element tagname AND
  834. // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
  835. // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
  836. _basicCustomElementTest(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) ||
  837. // Alternative, second condition checks if it's an `is`-attribute, AND
  838. // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
  839. lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
  840. return false;
  841. }
  842. /* Check value is safe. First, is attr inert? If so, is safe */
  843. } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if (!value) ; else {
  844. return false;
  845. }
  846. return true;
  847. };
  848. /**
  849. * _basicCustomElementCheck
  850. * checks if at least one dash is included in tagName, and it's not the first char
  851. * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
  852. * @param {string} tagName name of the tag of the node to sanitize
  853. */
  854. var _basicCustomElementTest = function _basicCustomElementTest(tagName) {
  855. return tagName.indexOf('-') > 0;
  856. };
  857. /**
  858. * _sanitizeAttributes
  859. *
  860. * @protect attributes
  861. * @protect nodeName
  862. * @protect removeAttribute
  863. * @protect setAttribute
  864. *
  865. * @param {Node} currentNode to sanitize
  866. */
  867. var _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
  868. var attr = void 0;
  869. var value = void 0;
  870. var lcName = void 0;
  871. var l = void 0;
  872. /* Execute a hook if present */
  873. _executeHook('beforeSanitizeAttributes', currentNode, null);
  874. var attributes = currentNode.attributes;
  875. /* Check if we have attributes; if not we might have a text node */
  876. if (!attributes) {
  877. return;
  878. }
  879. var hookEvent = {
  880. attrName: '',
  881. attrValue: '',
  882. keepAttr: true,
  883. allowedAttributes: ALLOWED_ATTR
  884. };
  885. l = attributes.length;
  886. /* Go backwards over all attributes; safely remove bad ones */
  887. while (l--) {
  888. attr = attributes[l];
  889. var _attr = attr,
  890. name = _attr.name,
  891. namespaceURI = _attr.namespaceURI;
  892. value = stringTrim(attr.value);
  893. lcName = transformCaseFunc(name);
  894. /* Execute a hook if present */
  895. hookEvent.attrName = lcName;
  896. hookEvent.attrValue = value;
  897. hookEvent.keepAttr = true;
  898. hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
  899. _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
  900. value = hookEvent.attrValue;
  901. /* Did the hooks approve of the attribute? */
  902. if (hookEvent.forceKeepAttr) {
  903. continue;
  904. }
  905. /* Remove attribute */
  906. _removeAttribute(name, currentNode);
  907. /* Did the hooks approve of the attribute? */
  908. if (!hookEvent.keepAttr) {
  909. continue;
  910. }
  911. /* Work around a security issue in jQuery 3.0 */
  912. if (regExpTest(/\/>/i, value)) {
  913. _removeAttribute(name, currentNode);
  914. continue;
  915. }
  916. /* Sanitize attribute content to be template-safe */
  917. if (SAFE_FOR_TEMPLATES) {
  918. value = stringReplace(value, MUSTACHE_EXPR$$1, ' ');
  919. value = stringReplace(value, ERB_EXPR$$1, ' ');
  920. }
  921. /* Is `value` valid for this attribute? */
  922. var lcTag = transformCaseFunc(currentNode.nodeName);
  923. if (!_isValidAttribute(lcTag, lcName, value)) {
  924. continue;
  925. }
  926. /* Handle invalid data-* attribute set by try-catching it */
  927. try {
  928. if (namespaceURI) {
  929. currentNode.setAttributeNS(namespaceURI, name, value);
  930. } else {
  931. /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
  932. currentNode.setAttribute(name, value);
  933. }
  934. arrayPop(DOMPurify.removed);
  935. } catch (_) {}
  936. }
  937. /* Execute a hook if present */
  938. _executeHook('afterSanitizeAttributes', currentNode, null);
  939. };
  940. /**
  941. * _sanitizeShadowDOM
  942. *
  943. * @param {DocumentFragment} fragment to iterate over recursively
  944. */
  945. var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
  946. var shadowNode = void 0;
  947. var shadowIterator = _createIterator(fragment);
  948. /* Execute a hook if present */
  949. _executeHook('beforeSanitizeShadowDOM', fragment, null);
  950. while (shadowNode = shadowIterator.nextNode()) {
  951. /* Execute a hook if present */
  952. _executeHook('uponSanitizeShadowNode', shadowNode, null);
  953. /* Sanitize tags and elements */
  954. if (_sanitizeElements(shadowNode)) {
  955. continue;
  956. }
  957. /* Deep shadow DOM detected */
  958. if (shadowNode.content instanceof DocumentFragment) {
  959. _sanitizeShadowDOM(shadowNode.content);
  960. }
  961. /* Check attributes, sanitize if necessary */
  962. _sanitizeAttributes(shadowNode);
  963. }
  964. /* Execute a hook if present */
  965. _executeHook('afterSanitizeShadowDOM', fragment, null);
  966. };
  967. /**
  968. * Sanitize
  969. * Public method providing core sanitation functionality
  970. *
  971. * @param {String|Node} dirty string or DOM node
  972. * @param {Object} configuration object
  973. */
  974. // eslint-disable-next-line complexity
  975. DOMPurify.sanitize = function (dirty, cfg) {
  976. var body = void 0;
  977. var importedNode = void 0;
  978. var currentNode = void 0;
  979. var oldNode = void 0;
  980. var returnNode = void 0;
  981. /* Make sure we have a string to sanitize.
  982. DO NOT return early, as this will return the wrong type if
  983. the user has requested a DOM object rather than a string */
  984. IS_EMPTY_INPUT = !dirty;
  985. if (IS_EMPTY_INPUT) {
  986. dirty = '<!-->';
  987. }
  988. /* Stringify, in case dirty is an object */
  989. if (typeof dirty !== 'string' && !_isNode(dirty)) {
  990. // eslint-disable-next-line no-negated-condition
  991. if (typeof dirty.toString !== 'function') {
  992. throw typeErrorCreate('toString is not a function');
  993. } else {
  994. dirty = dirty.toString();
  995. if (typeof dirty !== 'string') {
  996. throw typeErrorCreate('dirty is not a string, aborting');
  997. }
  998. }
  999. }
  1000. /* Check we can run. Otherwise fall back or ignore */
  1001. if (!DOMPurify.isSupported) {
  1002. if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') {
  1003. if (typeof dirty === 'string') {
  1004. return window.toStaticHTML(dirty);
  1005. }
  1006. if (_isNode(dirty)) {
  1007. return window.toStaticHTML(dirty.outerHTML);
  1008. }
  1009. }
  1010. return dirty;
  1011. }
  1012. /* Assign config vars */
  1013. if (!SET_CONFIG) {
  1014. _parseConfig(cfg);
  1015. }
  1016. /* Clean up removed elements */
  1017. DOMPurify.removed = [];
  1018. /* Check if dirty is correctly typed for IN_PLACE */
  1019. if (typeof dirty === 'string') {
  1020. IN_PLACE = false;
  1021. }
  1022. if (IN_PLACE) {
  1023. /* Do some early pre-sanitization to avoid unsafe root nodes */
  1024. if (dirty.nodeName) {
  1025. var tagName = transformCaseFunc(dirty.nodeName);
  1026. if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
  1027. throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
  1028. }
  1029. }
  1030. } else if (dirty instanceof Node) {
  1031. /* If dirty is a DOM element, append to an empty document to avoid
  1032. elements being stripped by the parser */
  1033. body = _initDocument('<!---->');
  1034. importedNode = body.ownerDocument.importNode(dirty, true);
  1035. if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
  1036. /* Node is already a body, use as is */
  1037. body = importedNode;
  1038. } else if (importedNode.nodeName === 'HTML') {
  1039. body = importedNode;
  1040. } else {
  1041. // eslint-disable-next-line unicorn/prefer-dom-node-append
  1042. body.appendChild(importedNode);
  1043. }
  1044. } else {
  1045. /* Exit directly if we have nothing to do */
  1046. if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
  1047. // eslint-disable-next-line unicorn/prefer-includes
  1048. dirty.indexOf('<') === -1) {
  1049. return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
  1050. }
  1051. /* Initialize the document to work on */
  1052. body = _initDocument(dirty);
  1053. /* Check we have a DOM node from the data */
  1054. if (!body) {
  1055. return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
  1056. }
  1057. }
  1058. /* Remove first element node (ours) if FORCE_BODY is set */
  1059. if (body && FORCE_BODY) {
  1060. _forceRemove(body.firstChild);
  1061. }
  1062. /* Get node iterator */
  1063. var nodeIterator = _createIterator(IN_PLACE ? dirty : body);
  1064. /* Now start iterating over the created document */
  1065. while (currentNode = nodeIterator.nextNode()) {
  1066. /* Fix IE's strange behavior with manipulated textNodes #89 */
  1067. if (currentNode.nodeType === 3 && currentNode === oldNode) {
  1068. continue;
  1069. }
  1070. /* Sanitize tags and elements */
  1071. if (_sanitizeElements(currentNode)) {
  1072. continue;
  1073. }
  1074. /* Shadow DOM detected, sanitize it */
  1075. if (currentNode.content instanceof DocumentFragment) {
  1076. _sanitizeShadowDOM(currentNode.content);
  1077. }
  1078. /* Check attributes, sanitize if necessary */
  1079. _sanitizeAttributes(currentNode);
  1080. oldNode = currentNode;
  1081. }
  1082. oldNode = null;
  1083. /* If we sanitized `dirty` in-place, return it. */
  1084. if (IN_PLACE) {
  1085. return dirty;
  1086. }
  1087. /* Return sanitized string or DOM */
  1088. if (RETURN_DOM) {
  1089. if (RETURN_DOM_FRAGMENT) {
  1090. returnNode = createDocumentFragment.call(body.ownerDocument);
  1091. while (body.firstChild) {
  1092. // eslint-disable-next-line unicorn/prefer-dom-node-append
  1093. returnNode.appendChild(body.firstChild);
  1094. }
  1095. } else {
  1096. returnNode = body;
  1097. }
  1098. if (ALLOWED_ATTR.shadowroot) {
  1099. /*
  1100. AdoptNode() is not used because internal state is not reset
  1101. (e.g. the past names map of a HTMLFormElement), this is safe
  1102. in theory but we would rather not risk another attack vector.
  1103. The state that is cloned by importNode() is explicitly defined
  1104. by the specs.
  1105. */
  1106. returnNode = importNode.call(originalDocument, returnNode, true);
  1107. }
  1108. return returnNode;
  1109. }
  1110. var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
  1111. /* Serialize doctype if allowed */
  1112. if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
  1113. serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
  1114. }
  1115. /* Sanitize final string template-safe */
  1116. if (SAFE_FOR_TEMPLATES) {
  1117. serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$$1, ' ');
  1118. serializedHTML = stringReplace(serializedHTML, ERB_EXPR$$1, ' ');
  1119. }
  1120. return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
  1121. };
  1122. /**
  1123. * Public method to set the configuration once
  1124. * setConfig
  1125. *
  1126. * @param {Object} cfg configuration object
  1127. */
  1128. DOMPurify.setConfig = function (cfg) {
  1129. _parseConfig(cfg);
  1130. SET_CONFIG = true;
  1131. };
  1132. /**
  1133. * Public method to remove the configuration
  1134. * clearConfig
  1135. *
  1136. */
  1137. DOMPurify.clearConfig = function () {
  1138. CONFIG = null;
  1139. SET_CONFIG = false;
  1140. };
  1141. /**
  1142. * Public method to check if an attribute value is valid.
  1143. * Uses last set config, if any. Otherwise, uses config defaults.
  1144. * isValidAttribute
  1145. *
  1146. * @param {string} tag Tag name of containing element.
  1147. * @param {string} attr Attribute name.
  1148. * @param {string} value Attribute value.
  1149. * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
  1150. */
  1151. DOMPurify.isValidAttribute = function (tag, attr, value) {
  1152. /* Initialize shared config vars if necessary. */
  1153. if (!CONFIG) {
  1154. _parseConfig({});
  1155. }
  1156. var lcTag = transformCaseFunc(tag);
  1157. var lcName = transformCaseFunc(attr);
  1158. return _isValidAttribute(lcTag, lcName, value);
  1159. };
  1160. /**
  1161. * AddHook
  1162. * Public method to add DOMPurify hooks
  1163. *
  1164. * @param {String} entryPoint entry point for the hook to add
  1165. * @param {Function} hookFunction function to execute
  1166. */
  1167. DOMPurify.addHook = function (entryPoint, hookFunction) {
  1168. if (typeof hookFunction !== 'function') {
  1169. return;
  1170. }
  1171. hooks[entryPoint] = hooks[entryPoint] || [];
  1172. arrayPush(hooks[entryPoint], hookFunction);
  1173. };
  1174. /**
  1175. * RemoveHook
  1176. * Public method to remove a DOMPurify hook at a given entryPoint
  1177. * (pops it from the stack of hooks if more are present)
  1178. *
  1179. * @param {String} entryPoint entry point for the hook to remove
  1180. */
  1181. DOMPurify.removeHook = function (entryPoint) {
  1182. if (hooks[entryPoint]) {
  1183. arrayPop(hooks[entryPoint]);
  1184. }
  1185. };
  1186. /**
  1187. * RemoveHooks
  1188. * Public method to remove all DOMPurify hooks at a given entryPoint
  1189. *
  1190. * @param {String} entryPoint entry point for the hooks to remove
  1191. */
  1192. DOMPurify.removeHooks = function (entryPoint) {
  1193. if (hooks[entryPoint]) {
  1194. hooks[entryPoint] = [];
  1195. }
  1196. };
  1197. /**
  1198. * RemoveAllHooks
  1199. * Public method to remove all DOMPurify hooks
  1200. *
  1201. */
  1202. DOMPurify.removeAllHooks = function () {
  1203. hooks = {};
  1204. };
  1205. return DOMPurify;
  1206. }
  1207. var purify = createDOMPurify();
  1208. module.exports = purify;
  1209. //# sourceMappingURL=purify.cjs.js.map