purify.es.js 56 KB

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