dompurify
Advanced tools
Comparing version 2.3.6 to 2.3.7
@@ -1,7 +0,87 @@ | ||
/*! @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 */ | ||
/*! @license DOMPurify 2.3.7 | (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.7/LICENSE */ | ||
'use strict'; | ||
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); } } | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { | ||
return typeof obj; | ||
} : function (obj) { | ||
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}, _typeof(obj); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _construct(Parent, args, Class) { | ||
if (_isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
} else { | ||
_construct = function _construct(Parent, args, Class) { | ||
var a = [null]; | ||
a.push.apply(a, args); | ||
var Constructor = Function.bind.apply(Parent, a); | ||
var instance = new Constructor(); | ||
if (Class) _setPrototypeOf(instance, Class.prototype); | ||
return instance; | ||
}; | ||
} | ||
return _construct.apply(null, arguments); | ||
} | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) return _arrayLikeToArray(arr); | ||
} | ||
function _iterableToArray(iter) { | ||
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
var hasOwnProperty = Object.hasOwnProperty, | ||
@@ -40,3 +120,3 @@ setPrototypeOf = Object.setPrototypeOf, | ||
construct = function construct(Func, args) { | ||
return new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))(); | ||
return _construct(Func, _toConsumableArray(args)); | ||
}; | ||
@@ -48,3 +128,2 @@ } | ||
var arrayPush = unapply(Array.prototype.push); | ||
var stringToLowerCase = unapply(String.prototype.toLowerCase); | ||
@@ -55,10 +134,7 @@ var stringMatch = unapply(String.prototype.match); | ||
var stringTrim = unapply(String.prototype.trim); | ||
var regExpTest = unapply(RegExp.prototype.test); | ||
var typeErrorCreate = unconstruct(TypeError); | ||
function unapply(func) { | ||
return function (thisArg) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
@@ -70,6 +146,5 @@ } | ||
} | ||
function unconstruct(func) { | ||
return function () { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
@@ -81,4 +156,4 @@ } | ||
} | ||
/* Add properties to a lookup table */ | ||
/* Add properties to a lookup table */ | ||
function addToSet(set, array) { | ||
@@ -93,6 +168,9 @@ if (setPrototypeOf) { | ||
var l = array.length; | ||
while (l--) { | ||
var element = array[l]; | ||
if (typeof element === 'string') { | ||
var lcElement = stringToLowerCase(element); | ||
if (lcElement !== element) { | ||
@@ -113,8 +191,8 @@ // Config presets (e.g. tags.js, attrs.js) are immutable. | ||
} | ||
/* Shallow clone an object */ | ||
/* Shallow clone an object */ | ||
function clone(object) { | ||
var newObject = create(null); | ||
var property; | ||
var property = void 0; | ||
for (property in object) { | ||
@@ -128,3 +206,2 @@ if (apply(hasOwnProperty, object, [property])) { | ||
} | ||
/* IE10 doesn't support __lookupGetter__ so lets' | ||
@@ -134,5 +211,7 @@ * simulate it. It also automatically checks | ||
* accordingly. */ | ||
function lookupGetter(object, prop) { | ||
while (object !== null) { | ||
var desc = getOwnPropertyDescriptor(object, prop); | ||
if (desc) { | ||
@@ -159,36 +238,29 @@ if (desc.get) { | ||
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']); | ||
var html$1 = 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']); // SVG | ||
// SVG | ||
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']); | ||
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']); | ||
// List of SVG elements that are disallowed by default. | ||
var svg$1 = 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']); | ||
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']); // List of SVG elements that are disallowed by default. | ||
// We still need to know them so that we can do namespace | ||
// checks properly in case one wants to add them to | ||
// allow-list. | ||
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']); | ||
var mathMl$1 = 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']); // Similarly to SVG, we want to know all MathML elements, | ||
// even those that we disallow by default. | ||
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']); | ||
// Similarly to SVG, we want to know all MathML elements, | ||
// even those that we disallow by default. | ||
var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); | ||
var text = freeze(['#text']); | ||
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']); | ||
var html = 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']); | ||
var svg = 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']); | ||
var mathMl = 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']); | ||
var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); | ||
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']); | ||
var MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode | ||
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']); | ||
var ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm); | ||
var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape | ||
var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); | ||
var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape | ||
// eslint-disable-next-line unicorn/better-regex | ||
var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode | ||
var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm); | ||
var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape | ||
var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape | ||
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 | ||
@@ -201,10 +273,5 @@ ); | ||
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; }; | ||
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); } } | ||
var getGlobal = function getGlobal() { | ||
return typeof window === 'undefined' ? null : window; | ||
}; | ||
/** | ||
@@ -218,12 +285,15 @@ * Creates a no-op policy for internal use only. | ||
*/ | ||
var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) { | ||
if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') { | ||
if (_typeof(trustedTypes) !== 'object' || typeof trustedTypes.createPolicy !== 'function') { | ||
return null; | ||
} | ||
// Allow the callers to control the unique policy name | ||
} // Allow the callers to control the unique policy name | ||
// by adding a data-tt-policy-suffix to the script element with the DOMPurify. | ||
// Policy creation with duplicate names throws in Trusted Types. | ||
var suffix = null; | ||
var ATTR_NAME = 'data-tt-policy-suffix'; | ||
if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) { | ||
@@ -237,4 +307,4 @@ suffix = document.currentScript.getAttribute(ATTR_NAME); | ||
return trustedTypes.createPolicy(policyName, { | ||
createHTML: function createHTML(html$$1) { | ||
return html$$1; | ||
createHTML: function createHTML(html) { | ||
return html; | ||
} | ||
@@ -257,3 +327,2 @@ }); | ||
}; | ||
/** | ||
@@ -263,4 +332,5 @@ * Version label, exposed for easier checks | ||
*/ | ||
DOMPurify.version = '2.3.6'; | ||
DOMPurify.version = '2.3.7'; | ||
/** | ||
@@ -270,2 +340,3 @@ * Array of elements that DOMPurify removed during sanitation. | ||
*/ | ||
DOMPurify.removed = []; | ||
@@ -277,3 +348,2 @@ | ||
DOMPurify.isSupported = false; | ||
return DOMPurify; | ||
@@ -283,3 +353,2 @@ } | ||
var originalDocument = window.document; | ||
var document = window.document; | ||
@@ -292,16 +361,11 @@ var DocumentFragment = window.DocumentFragment, | ||
_window$NamedNodeMap = window.NamedNodeMap, | ||
NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap, | ||
NamedNodeMap = _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap, | ||
HTMLFormElement = window.HTMLFormElement, | ||
DOMParser = window.DOMParser, | ||
trustedTypes = window.trustedTypes; | ||
var ElementPrototype = Element.prototype; | ||
var cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); | ||
var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); | ||
var getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); | ||
var getParentNode = lookupGetter(ElementPrototype, 'parentNode'); | ||
// As per issue #47, the web-components registry is inherited by a | ||
var getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a | ||
// new document created via createHTMLDocument. As per the spec | ||
@@ -312,4 +376,6 @@ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) | ||
// is inherited. | ||
if (typeof HTMLTemplateElement === 'function') { | ||
var template = document.createElement('template'); | ||
if (template.content && template.content.ownerDocument) { | ||
@@ -321,4 +387,4 @@ document = template.content.ownerDocument; | ||
var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument); | ||
var emptyHTML = trustedTypesPolicy ? trustedTypesPolicy.createHTML('') : ''; | ||
var _document = document, | ||
@@ -330,5 +396,4 @@ implementation = _document.implementation, | ||
var importNode = originalDocument.importNode; | ||
var documentMode = {}; | ||
var documentMode = {}; | ||
try { | ||
@@ -339,16 +404,14 @@ documentMode = clone(document).documentMode ? document.documentMode : {}; | ||
var hooks = {}; | ||
/** | ||
* Expose whether this browser supports running the full DOMPurify. | ||
*/ | ||
DOMPurify.isSupported = typeof getParentNode === 'function' && implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9; | ||
var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR, | ||
ERB_EXPR$$1 = ERB_EXPR, | ||
DATA_ATTR$$1 = DATA_ATTR, | ||
ARIA_ATTR$$1 = ARIA_ATTR, | ||
IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA, | ||
ATTR_WHITESPACE$$1 = ATTR_WHITESPACE; | ||
var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI; | ||
var MUSTACHE_EXPR$1 = MUSTACHE_EXPR, | ||
ERB_EXPR$1 = ERB_EXPR, | ||
DATA_ATTR$1 = DATA_ATTR, | ||
ARIA_ATTR$1 = ARIA_ATTR, | ||
IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, | ||
ATTR_WHITESPACE$1 = ATTR_WHITESPACE; | ||
var IS_ALLOWED_URI$1 = IS_ALLOWED_URI; | ||
/** | ||
@@ -362,8 +425,7 @@ * We consider the elements and attributes below to be safe. Ideally | ||
var ALLOWED_TAGS = null; | ||
var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(html), _toConsumableArray$1(svg), _toConsumableArray$1(svgFilters), _toConsumableArray$1(mathMl), _toConsumableArray$1(text))); | ||
var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray(html$1), _toConsumableArray(svg$1), _toConsumableArray(svgFilters), _toConsumableArray(mathMl$1), _toConsumableArray(text))); | ||
/* Allowed attribute names */ | ||
/* Allowed attribute names */ | ||
var ALLOWED_ATTR = null; | ||
var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray$1(html$1), _toConsumableArray$1(svg$1), _toConsumableArray$1(mathMl$1), _toConsumableArray$1(xml))); | ||
var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray(html), _toConsumableArray(svg), _toConsumableArray(mathMl), _toConsumableArray(xml))); | ||
/* | ||
@@ -375,2 +437,3 @@ * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements. | ||
*/ | ||
var CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, { | ||
@@ -396,33 +459,32 @@ tagNameCheck: { | ||
})); | ||
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ | ||
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ | ||
var FORBID_TAGS = null; | ||
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ | ||
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ | ||
var FORBID_ATTR = null; | ||
/* Decide if ARIA attributes are okay */ | ||
/* Decide if ARIA attributes are okay */ | ||
var ALLOW_ARIA_ATTR = true; | ||
/* Decide if custom data attributes are okay */ | ||
/* Decide if custom data attributes are okay */ | ||
var ALLOW_DATA_ATTR = true; | ||
/* Decide if unknown protocols are okay */ | ||
/* Decide if unknown protocols are okay */ | ||
var ALLOW_UNKNOWN_PROTOCOLS = false; | ||
/* Output should be safe for common template engines. | ||
* This means, DOMPurify removes data attributes, mustaches and ERB | ||
*/ | ||
var SAFE_FOR_TEMPLATES = false; | ||
/* Decide if document with <html>... should be returned */ | ||
/* Decide if document with <html>... should be returned */ | ||
var WHOLE_DOCUMENT = false; | ||
/* Track whether config is already set on this instance of DOMPurify. */ | ||
/* Track whether config is already set on this instance of DOMPurify. */ | ||
var SET_CONFIG = false; | ||
/* Decide if all elements (e.g. style, script) must be children of | ||
* document.body. By default, browsers might move them to document.head */ | ||
var FORCE_BODY = false; | ||
/* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html | ||
@@ -432,37 +494,37 @@ * string (or a TrustedHTML object if Trusted Types are supported). | ||
*/ | ||
var RETURN_DOM = false; | ||
/* Decide if a DOM `DocumentFragment` should be returned, instead of a html | ||
* string (or a TrustedHTML object if Trusted Types are supported) */ | ||
var RETURN_DOM_FRAGMENT = false; | ||
/* Try to return a Trusted Type object instead of a string, return a string in | ||
* case Trusted Types are not supported */ | ||
var RETURN_TRUSTED_TYPE = false; | ||
/* Output should be free from DOM clobbering attacks? */ | ||
/* Output should be free from DOM clobbering attacks? */ | ||
var SANITIZE_DOM = true; | ||
/* Keep element content when removing element? */ | ||
/* Keep element content when removing element? */ | ||
var KEEP_CONTENT = true; | ||
/* If a `Node` is passed to sanitize(), then performs sanitization in-place instead | ||
* of importing it into a new Document and returning a sanitized copy */ | ||
var IN_PLACE = false; | ||
/* Allow usage of profiles like html, svg and mathMl */ | ||
/* Allow usage of profiles like html, svg and mathMl */ | ||
var USE_PROFILES = {}; | ||
/* Tags to ignore content of when KEEP_CONTENT is true */ | ||
/* Tags to ignore content of when KEEP_CONTENT is true */ | ||
var FORBID_CONTENTS = null; | ||
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']); | ||
/* Tags that are safe for data: URIs */ | ||
/* Tags that are safe for data: URIs */ | ||
var DATA_URI_TAGS = null; | ||
var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); | ||
/* Attributes safe for values like "javascript:" */ | ||
/* Attributes safe for values like "javascript:" */ | ||
var URI_SAFE_ATTRIBUTES = null; | ||
var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']); | ||
var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; | ||
@@ -472,15 +534,16 @@ var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; | ||
/* Document namespace */ | ||
var NAMESPACE = HTML_NAMESPACE; | ||
var IS_EMPTY_INPUT = false; | ||
/* Parsing of strict XHTML documents */ | ||
/* Parsing of strict XHTML documents */ | ||
var PARSER_MEDIA_TYPE = void 0; | ||
var PARSER_MEDIA_TYPE; | ||
var SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html']; | ||
var DEFAULT_PARSER_MEDIA_TYPE = 'text/html'; | ||
var transformCaseFunc = void 0; | ||
var transformCaseFunc; | ||
/* Keep a reference to config to pass to hooks */ | ||
/* Keep a reference to config to pass to hooks */ | ||
var CONFIG = null; | ||
/* Ideally, do not touch anything below this line */ | ||
/* Ideally, do not touch anything below this line */ | ||
/* ______________________________________________ */ | ||
@@ -493,3 +556,2 @@ | ||
}; | ||
/** | ||
@@ -501,2 +563,4 @@ * _parseConfig | ||
// eslint-disable-next-line complexity | ||
var _parseConfig = function _parseConfig(cfg) { | ||
@@ -506,12 +570,14 @@ if (CONFIG && CONFIG === cfg) { | ||
} | ||
/* Shield configuration object from tampering */ | ||
/* Shield configuration object from tampering */ | ||
if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') { | ||
if (!cfg || _typeof(cfg) !== 'object') { | ||
cfg = {}; | ||
} | ||
/* Shield configuration object from prototype pollution */ | ||
/* Shield configuration object from prototype pollution */ | ||
cfg = clone(cfg); | ||
/* Set configuration parameters */ | ||
/* Set configuration parameters */ | ||
ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS; | ||
@@ -526,15 +592,28 @@ ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR; | ||
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true | ||
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true | ||
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false | ||
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false | ||
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false | ||
RETURN_DOM = cfg.RETURN_DOM || false; // Default false | ||
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false | ||
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false | ||
FORCE_BODY = cfg.FORCE_BODY || false; // Default false | ||
SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true | ||
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true | ||
IN_PLACE = cfg.IN_PLACE || false; // Default false | ||
IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1; | ||
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$1; | ||
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE; | ||
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) { | ||
@@ -552,7 +631,5 @@ CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck; | ||
PARSER_MEDIA_TYPE = | ||
// eslint-disable-next-line unicorn/prefer-includes | ||
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; | ||
PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes | ||
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. | ||
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. | ||
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? function (x) { | ||
@@ -569,15 +646,17 @@ return x; | ||
} | ||
/* Parse profile info */ | ||
/* Parse profile info */ | ||
if (USE_PROFILES) { | ||
ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(text))); | ||
ALLOWED_TAGS = addToSet({}, _toConsumableArray(text)); | ||
ALLOWED_ATTR = []; | ||
if (USE_PROFILES.html === true) { | ||
addToSet(ALLOWED_TAGS, html); | ||
addToSet(ALLOWED_ATTR, html$1); | ||
addToSet(ALLOWED_TAGS, html$1); | ||
addToSet(ALLOWED_ATTR, html); | ||
} | ||
if (USE_PROFILES.svg === true) { | ||
addToSet(ALLOWED_TAGS, svg); | ||
addToSet(ALLOWED_ATTR, svg$1); | ||
addToSet(ALLOWED_TAGS, svg$1); | ||
addToSet(ALLOWED_ATTR, svg); | ||
addToSet(ALLOWED_ATTR, xml); | ||
@@ -588,3 +667,3 @@ } | ||
addToSet(ALLOWED_TAGS, svgFilters); | ||
addToSet(ALLOWED_ATTR, svg$1); | ||
addToSet(ALLOWED_ATTR, svg); | ||
addToSet(ALLOWED_ATTR, xml); | ||
@@ -594,9 +673,10 @@ } | ||
if (USE_PROFILES.mathMl === true) { | ||
addToSet(ALLOWED_TAGS, mathMl); | ||
addToSet(ALLOWED_ATTR, mathMl$1); | ||
addToSet(ALLOWED_TAGS, mathMl$1); | ||
addToSet(ALLOWED_ATTR, mathMl); | ||
addToSet(ALLOWED_ATTR, xml); | ||
} | ||
} | ||
/* Merge configuration parameters */ | ||
/* Merge configuration parameters */ | ||
if (cfg.ADD_TAGS) { | ||
@@ -629,21 +709,24 @@ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { | ||
} | ||
/* Add #text in case KEEP_CONTENT is set to true */ | ||
/* Add #text in case KEEP_CONTENT is set to true */ | ||
if (KEEP_CONTENT) { | ||
ALLOWED_TAGS['#text'] = true; | ||
} | ||
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ | ||
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ | ||
if (WHOLE_DOCUMENT) { | ||
addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); | ||
} | ||
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ | ||
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ | ||
if (ALLOWED_TAGS.table) { | ||
addToSet(ALLOWED_TAGS, ['tbody']); | ||
delete FORBID_TAGS.tbody; | ||
} | ||
} // Prevent further manipulation of configuration. | ||
// Not available in IE8, Safari 5, etc. | ||
// Prevent further manipulation of configuration. | ||
// Not available in IE8, Safari 5, etc. | ||
if (freeze) { | ||
@@ -657,15 +740,17 @@ freeze(cfg); | ||
var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); | ||
var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); // Certain elements are allowed in both SVG and HTML | ||
// namespace. We need to specify them explicitly | ||
// so that they don't get erroneously deleted from | ||
// HTML namespace. | ||
var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); | ||
var COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']); | ||
/* Keep track of all possible SVG and MathML tags | ||
* so that we can perform the namespace checks | ||
* correctly. */ | ||
var ALL_SVG_TAGS = addToSet({}, svg); | ||
var ALL_SVG_TAGS = addToSet({}, svg$1); | ||
addToSet(ALL_SVG_TAGS, svgFilters); | ||
addToSet(ALL_SVG_TAGS, svgDisallowed); | ||
var ALL_MATHML_TAGS = addToSet({}, mathMl); | ||
var ALL_MATHML_TAGS = addToSet({}, mathMl$1); | ||
addToSet(ALL_MATHML_TAGS, mathMlDisallowed); | ||
/** | ||
@@ -679,7 +764,7 @@ * | ||
*/ | ||
var _checkValidNamespace = function _checkValidNamespace(element) { | ||
var parent = getParentNode(element); | ||
var parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode | ||
// can be null. We just simulate parent in this case. | ||
// In JSDOM, if we're inside shadow DOM, then parentNode | ||
// can be null. We just simulate parent in this case. | ||
if (!parent || !parent.tagName) { | ||
@@ -701,13 +786,13 @@ parent = { | ||
return tagName === 'svg'; | ||
} | ||
// The only way to switch from MathML to SVG is via | ||
} // The only way to switch from MathML to SVG is via | ||
// svg if parent is either <annotation-xml> or MathML | ||
// text integration points. | ||
if (parent.namespaceURI === MATHML_NAMESPACE) { | ||
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); | ||
} | ||
} // We only allow elements that are defined in SVG | ||
// spec. All others are disallowed in SVG namespace. | ||
// We only allow elements that are defined in SVG | ||
// spec. All others are disallowed in SVG namespace. | ||
return Boolean(ALL_SVG_TAGS[tagName]); | ||
@@ -722,12 +807,12 @@ } | ||
return tagName === 'math'; | ||
} | ||
} // The only way to switch from SVG to MathML is via | ||
// <math> and HTML integration points | ||
// The only way to switch from SVG to MathML is via | ||
// <math> and HTML integration points | ||
if (parent.namespaceURI === SVG_NAMESPACE) { | ||
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; | ||
} | ||
} // We only allow elements that are defined in MathML | ||
// spec. All others are disallowed in MathML namespace. | ||
// We only allow elements that are defined in MathML | ||
// spec. All others are disallowed in MathML namespace. | ||
return Boolean(ALL_MATHML_TAGS[tagName]); | ||
@@ -746,21 +831,14 @@ } | ||
return false; | ||
} | ||
} // We disallow tags that are specific for MathML | ||
// or SVG and should never appear in HTML namespace | ||
// Certain elements are allowed in both SVG and HTML | ||
// namespace. We need to specify them explicitly | ||
// so that they don't get erronously deleted from | ||
// HTML namespace. | ||
var commonSvgAndHTMLElements = addToSet({}, ['title', 'style', 'font', 'a', 'script']); | ||
// We disallow tags that are specific for MathML | ||
// or SVG and should never appear in HTML namespace | ||
return !ALL_MATHML_TAGS[tagName] && (commonSvgAndHTMLElements[tagName] || !ALL_SVG_TAGS[tagName]); | ||
} | ||
// The code should never reach this place (this means | ||
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]); | ||
} // The code should never reach this place (this means | ||
// that the element somehow got namespace that is not | ||
// HTML, SVG or MathML). Return false just in case. | ||
return false; | ||
}; | ||
/** | ||
@@ -771,4 +849,9 @@ * _forceRemove | ||
*/ | ||
var _forceRemove = function _forceRemove(node) { | ||
arrayPush(DOMPurify.removed, { element: node }); | ||
arrayPush(DOMPurify.removed, { | ||
element: node | ||
}); | ||
try { | ||
@@ -785,3 +868,2 @@ // eslint-disable-next-line unicorn/prefer-dom-node-remove | ||
}; | ||
/** | ||
@@ -793,2 +875,4 @@ * _removeAttribute | ||
*/ | ||
var _removeAttribute = function _removeAttribute(name, node) { | ||
@@ -807,5 +891,4 @@ try { | ||
node.removeAttribute(name); | ||
node.removeAttribute(name); // We void attribute values for unremovable "is"" attributes | ||
// We void attribute values for unremovable "is"" attributes | ||
if (name === 'is' && !ALLOWED_ATTR[name]) { | ||
@@ -823,3 +906,2 @@ if (RETURN_DOM || RETURN_DOM_FRAGMENT) { | ||
}; | ||
/** | ||
@@ -831,6 +913,8 @@ * _initDocument | ||
*/ | ||
var _initDocument = function _initDocument(dirty) { | ||
/* Create a HTML document */ | ||
var doc = void 0; | ||
var leadingWhitespace = void 0; | ||
var doc; | ||
var leadingWhitespace; | ||
@@ -855,2 +939,3 @@ if (FORCE_BODY) { | ||
*/ | ||
if (NAMESPACE === HTML_NAMESPACE) { | ||
@@ -861,10 +946,11 @@ try { | ||
} | ||
/* Use createHTMLDocument in case DOMParser is not available */ | ||
/* Use createHTMLDocument in case DOMParser is not available */ | ||
if (!doc || !doc.documentElement) { | ||
doc = implementation.createDocument(NAMESPACE, 'template', null); | ||
try { | ||
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? '' : dirtyPayload; | ||
} catch (_) { | ||
// Syntax error if dirtyPayload is invalid xml | ||
} catch (_) {// Syntax error if dirtyPayload is invalid xml | ||
} | ||
@@ -878,4 +964,5 @@ } | ||
} | ||
/* Work on whole document or just its body */ | ||
/* Work on whole document or just its body */ | ||
if (NAMESPACE === HTML_NAMESPACE) { | ||
@@ -887,3 +974,2 @@ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; | ||
}; | ||
/** | ||
@@ -895,8 +981,8 @@ * _createIterator | ||
*/ | ||
var _createIterator = function _createIterator(root) { | ||
return createNodeIterator.call(root.ownerDocument || root, root, | ||
// eslint-disable-next-line no-bitwise | ||
return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise | ||
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false); | ||
}; | ||
/** | ||
@@ -908,6 +994,7 @@ * _isClobbered | ||
*/ | ||
var _isClobbered = function _isClobbered(elm) { | ||
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'); | ||
}; | ||
/** | ||
@@ -919,6 +1006,7 @@ * _isNode | ||
*/ | ||
var _isNode = function _isNode(object) { | ||
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'; | ||
return _typeof(Node) === 'object' ? object instanceof Node : object && _typeof(object) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'; | ||
}; | ||
/** | ||
@@ -932,2 +1020,4 @@ * _executeHook | ||
*/ | ||
var _executeHook = function _executeHook(entryPoint, currentNode, data) { | ||
@@ -942,3 +1032,2 @@ if (!hooks[entryPoint]) { | ||
}; | ||
/** | ||
@@ -954,24 +1043,31 @@ * _sanitizeElements | ||
*/ | ||
var _sanitizeElements = function _sanitizeElements(currentNode) { | ||
var content = void 0; | ||
var content; | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('beforeSanitizeElements', currentNode, null); | ||
/* Check if element is clobbered or can clobber */ | ||
/* Check if element is clobbered or can clobber */ | ||
if (_isClobbered(currentNode)) { | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Check if tagname contains Unicode */ | ||
/* Check if tagname contains Unicode */ | ||
if (stringMatch(currentNode.nodeName, /[\u0080-\uFFFF]/)) { | ||
if (regExpTest(/[\u0080-\uFFFF]/, currentNode.nodeName)) { | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Now let's check the element's type and name */ | ||
/* Now let's check the element's type and name */ | ||
var tagName = transformCaseFunc(currentNode.nodeName); | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('uponSanitizeElement', currentNode, { | ||
@@ -981,16 +1077,21 @@ tagName: tagName, | ||
}); | ||
/* Detect mXSS attempts abusing namespace confusion */ | ||
/* Detect mXSS attempts abusing namespace confusion */ | ||
if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { | ||
if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Mitigate a problem with templates inside select */ | ||
/* Mitigate a problem with templates inside select */ | ||
if (tagName === 'select' && regExpTest(/<template/i, currentNode.innerHTML)) { | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Remove element if anything forbids its presence */ | ||
/* Remove element if anything forbids its presence */ | ||
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { | ||
@@ -1002,4 +1103,5 @@ /* Check if we have a custom element to handle */ | ||
} | ||
/* Keep content except for bad-listed elements */ | ||
/* Keep content except for bad-listed elements */ | ||
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { | ||
@@ -1019,8 +1121,11 @@ var parentNode = getParentNode(currentNode) || currentNode.parentNode; | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Check whether element has a valid namespace */ | ||
/* Check whether element has a valid namespace */ | ||
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { | ||
_forceRemove(currentNode); | ||
return true; | ||
@@ -1031,18 +1136,24 @@ } | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Sanitize element content to be template-safe */ | ||
/* Sanitize element content to be template-safe */ | ||
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) { | ||
/* Get the element's text content */ | ||
content = currentNode.textContent; | ||
content = stringReplace(content, MUSTACHE_EXPR$$1, ' '); | ||
content = stringReplace(content, ERB_EXPR$$1, ' '); | ||
content = stringReplace(content, MUSTACHE_EXPR$1, ' '); | ||
content = stringReplace(content, ERB_EXPR$1, ' '); | ||
if (currentNode.textContent !== content) { | ||
arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() }); | ||
arrayPush(DOMPurify.removed, { | ||
element: currentNode.cloneNode() | ||
}); | ||
currentNode.textContent = content; | ||
} | ||
} | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('afterSanitizeElements', currentNode, null); | ||
@@ -1052,3 +1163,2 @@ | ||
}; | ||
/** | ||
@@ -1063,2 +1173,4 @@ * _isValidAttribute | ||
// eslint-disable-next-line complexity | ||
var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) { | ||
@@ -1069,3 +1181,2 @@ /* Make sure attribute cannot clobber */ | ||
} | ||
/* Allow valid data-* attributes: At least one character after "-" | ||
@@ -1075,9 +1186,9 @@ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) | ||
We don't need to check the value; it's always URI safe. */ | ||
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]) { | ||
if ( | ||
// First condition does a very basic check if a) it's basically a valid custom element tagname AND | ||
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]) { | ||
if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND | ||
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck | ||
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck | ||
_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)) || | ||
// Alternative, second condition checks if it's an `is`-attribute, AND | ||
_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)) || // Alternative, second condition checks if it's an `is`-attribute, AND | ||
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck | ||
@@ -1088,3 +1199,4 @@ 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 { | ||
/* Check value is safe. First, is attr inert? If so, is safe */ | ||
} 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 { | ||
} 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 { | ||
return false; | ||
@@ -1095,3 +1207,2 @@ } | ||
}; | ||
/** | ||
@@ -1103,6 +1214,7 @@ * _basicCustomElementCheck | ||
*/ | ||
var _basicCustomElementTest = function _basicCustomElementTest(tagName) { | ||
return tagName.indexOf('-') > 0; | ||
}; | ||
/** | ||
@@ -1118,12 +1230,14 @@ * _sanitizeAttributes | ||
*/ | ||
var _sanitizeAttributes = function _sanitizeAttributes(currentNode) { | ||
var attr = void 0; | ||
var value = void 0; | ||
var lcName = void 0; | ||
var l = void 0; | ||
var attr; | ||
var value; | ||
var lcName; | ||
var l; | ||
/* Execute a hook if present */ | ||
_executeHook('beforeSanitizeAttributes', currentNode, null); | ||
var attributes = currentNode.attributes; | ||
/* Check if we have attributes; if not we might have a text node */ | ||
@@ -1142,4 +1256,4 @@ | ||
l = attributes.length; | ||
/* Go backwards over all attributes; safely remove bad ones */ | ||
/* Go backwards over all attributes; safely remove bad ones */ | ||
while (l--) { | ||
@@ -1150,7 +1264,6 @@ attr = attributes[l]; | ||
namespaceURI = _attr.namespaceURI; | ||
value = stringTrim(attr.value); | ||
value = name === 'value' ? attr.value : stringTrim(attr.value); | ||
lcName = transformCaseFunc(name); | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
hookEvent.attrName = lcName; | ||
@@ -1160,36 +1273,47 @@ hookEvent.attrValue = value; | ||
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set | ||
_executeHook('uponSanitizeAttribute', currentNode, hookEvent); | ||
value = hookEvent.attrValue; | ||
/* Did the hooks approve of the attribute? */ | ||
if (hookEvent.forceKeepAttr) { | ||
continue; | ||
} | ||
/* Remove attribute */ | ||
/* Remove attribute */ | ||
_removeAttribute(name, currentNode); | ||
/* Did the hooks approve of the attribute? */ | ||
/* Did the hooks approve of the attribute? */ | ||
if (!hookEvent.keepAttr) { | ||
continue; | ||
} | ||
/* Work around a security issue in jQuery 3.0 */ | ||
/* Work around a security issue in jQuery 3.0 */ | ||
if (regExpTest(/\/>/i, value)) { | ||
_removeAttribute(name, currentNode); | ||
continue; | ||
} | ||
/* Sanitize attribute content to be template-safe */ | ||
/* Sanitize attribute content to be template-safe */ | ||
if (SAFE_FOR_TEMPLATES) { | ||
value = stringReplace(value, MUSTACHE_EXPR$$1, ' '); | ||
value = stringReplace(value, ERB_EXPR$$1, ' '); | ||
value = stringReplace(value, MUSTACHE_EXPR$1, ' '); | ||
value = stringReplace(value, ERB_EXPR$1, ' '); | ||
} | ||
/* Is `value` valid for this attribute? */ | ||
/* Is `value` valid for this attribute? */ | ||
var lcTag = transformCaseFunc(currentNode.nodeName); | ||
if (!_isValidAttribute(lcTag, lcName, value)) { | ||
continue; | ||
} | ||
/* Handle invalid data-* attribute set by try-catching it */ | ||
/* Handle invalid data-* attribute set by try-catching it */ | ||
try { | ||
@@ -1206,7 +1330,7 @@ if (namespaceURI) { | ||
} | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('afterSanitizeAttributes', currentNode, null); | ||
}; | ||
/** | ||
@@ -1217,7 +1341,11 @@ * _sanitizeShadowDOM | ||
*/ | ||
var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) { | ||
var shadowNode = void 0; | ||
var shadowNode; | ||
var shadowIterator = _createIterator(fragment); | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('beforeSanitizeShadowDOM', fragment, null); | ||
@@ -1228,21 +1356,24 @@ | ||
_executeHook('uponSanitizeShadowNode', shadowNode, null); | ||
/* Sanitize tags and elements */ | ||
/* Sanitize tags and elements */ | ||
if (_sanitizeElements(shadowNode)) { | ||
continue; | ||
} | ||
/* Deep shadow DOM detected */ | ||
/* Deep shadow DOM detected */ | ||
if (shadowNode.content instanceof DocumentFragment) { | ||
_sanitizeShadowDOM(shadowNode.content); | ||
} | ||
/* Check attributes, sanitize if necessary */ | ||
/* Check attributes, sanitize if necessary */ | ||
_sanitizeAttributes(shadowNode); | ||
} | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('afterSanitizeShadowDOM', fragment, null); | ||
}; | ||
/** | ||
@@ -1256,17 +1387,22 @@ * Sanitize | ||
// eslint-disable-next-line complexity | ||
DOMPurify.sanitize = function (dirty, cfg) { | ||
var body = void 0; | ||
var importedNode = void 0; | ||
var currentNode = void 0; | ||
var oldNode = void 0; | ||
var returnNode = void 0; | ||
var body; | ||
var importedNode; | ||
var currentNode; | ||
var oldNode; | ||
var returnNode; | ||
/* Make sure we have a string to sanitize. | ||
DO NOT return early, as this will return the wrong type if | ||
the user has requested a DOM object rather than a string */ | ||
IS_EMPTY_INPUT = !dirty; | ||
if (IS_EMPTY_INPUT) { | ||
dirty = '<!-->'; | ||
} | ||
/* Stringify, in case dirty is an object */ | ||
/* Stringify, in case dirty is an object */ | ||
if (typeof dirty !== 'string' && !_isNode(dirty)) { | ||
@@ -1278,2 +1414,3 @@ // eslint-disable-next-line no-negated-condition | ||
dirty = dirty.toString(); | ||
if (typeof dirty !== 'string') { | ||
@@ -1284,4 +1421,5 @@ throw typeErrorCreate('dirty is not a string, aborting'); | ||
} | ||
/* Check we can run. Otherwise fall back or ignore */ | ||
/* Check we can run. Otherwise fall back or ignore */ | ||
if (!DOMPurify.isSupported) { | ||
@@ -1300,12 +1438,14 @@ if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') { | ||
} | ||
/* Assign config vars */ | ||
/* Assign config vars */ | ||
if (!SET_CONFIG) { | ||
_parseConfig(cfg); | ||
} | ||
/* Clean up removed elements */ | ||
/* Clean up removed elements */ | ||
DOMPurify.removed = []; | ||
/* Check if dirty is correctly typed for IN_PLACE */ | ||
/* Check if dirty is correctly typed for IN_PLACE */ | ||
if (typeof dirty === 'string') { | ||
@@ -1319,2 +1459,3 @@ IN_PLACE = false; | ||
var tagName = transformCaseFunc(dirty.nodeName); | ||
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { | ||
@@ -1329,2 +1470,3 @@ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place'); | ||
importedNode = body.ownerDocument.importNode(dirty, true); | ||
if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') { | ||
@@ -1341,12 +1483,12 @@ /* Node is already a body, use as is */ | ||
/* Exit directly if we have nothing to do */ | ||
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && | ||
// eslint-disable-next-line unicorn/prefer-includes | ||
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes | ||
dirty.indexOf('<') === -1) { | ||
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; | ||
} | ||
/* Initialize the document to work on */ | ||
/* Initialize the document to work on */ | ||
body = _initDocument(dirty); | ||
/* Check we have a DOM node from the data */ | ||
/* Check we have a DOM node from the data */ | ||
if (!body) { | ||
@@ -1356,12 +1498,15 @@ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : ''; | ||
} | ||
/* Remove first element node (ours) if FORCE_BODY is set */ | ||
/* Remove first element node (ours) if FORCE_BODY is set */ | ||
if (body && FORCE_BODY) { | ||
_forceRemove(body.firstChild); | ||
} | ||
/* Get node iterator */ | ||
/* Get node iterator */ | ||
var nodeIterator = _createIterator(IN_PLACE ? dirty : body); | ||
/* Now start iterating over the created document */ | ||
/* Now start iterating over the created document */ | ||
while (currentNode = nodeIterator.nextNode()) { | ||
@@ -1372,14 +1517,17 @@ /* Fix IE's strange behavior with manipulated textNodes #89 */ | ||
} | ||
/* Sanitize tags and elements */ | ||
/* Sanitize tags and elements */ | ||
if (_sanitizeElements(currentNode)) { | ||
continue; | ||
} | ||
/* Shadow DOM detected, sanitize it */ | ||
/* Shadow DOM detected, sanitize it */ | ||
if (currentNode.content instanceof DocumentFragment) { | ||
_sanitizeShadowDOM(currentNode.content); | ||
} | ||
/* Check attributes, sanitize if necessary */ | ||
/* Check attributes, sanitize if necessary */ | ||
_sanitizeAttributes(currentNode); | ||
@@ -1391,9 +1539,10 @@ | ||
oldNode = null; | ||
/* If we sanitized `dirty` in-place, return it. */ | ||
/* If we sanitized `dirty` in-place, return it. */ | ||
if (IN_PLACE) { | ||
return dirty; | ||
} | ||
/* Return sanitized string or DOM */ | ||
/* Return sanitized string or DOM */ | ||
if (RETURN_DOM) { | ||
@@ -1426,12 +1575,13 @@ if (RETURN_DOM_FRAGMENT) { | ||
var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; | ||
/* Serialize doctype if allowed */ | ||
/* Serialize doctype if allowed */ | ||
if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) { | ||
serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML; | ||
} | ||
/* Sanitize final string template-safe */ | ||
/* Sanitize final string template-safe */ | ||
if (SAFE_FOR_TEMPLATES) { | ||
serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$$1, ' '); | ||
serializedHTML = stringReplace(serializedHTML, ERB_EXPR$$1, ' '); | ||
serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$1, ' '); | ||
serializedHTML = stringReplace(serializedHTML, ERB_EXPR$1, ' '); | ||
} | ||
@@ -1441,3 +1591,2 @@ | ||
}; | ||
/** | ||
@@ -1449,7 +1598,9 @@ * Public method to set the configuration once | ||
*/ | ||
DOMPurify.setConfig = function (cfg) { | ||
_parseConfig(cfg); | ||
SET_CONFIG = true; | ||
}; | ||
/** | ||
@@ -1460,2 +1611,4 @@ * Public method to remove the configuration | ||
*/ | ||
DOMPurify.clearConfig = function () { | ||
@@ -1465,3 +1618,2 @@ CONFIG = null; | ||
}; | ||
/** | ||
@@ -1477,2 +1629,4 @@ * Public method to check if an attribute value is valid. | ||
*/ | ||
DOMPurify.isValidAttribute = function (tag, attr, value) { | ||
@@ -1488,3 +1642,2 @@ /* Initialize shared config vars if necessary. */ | ||
}; | ||
/** | ||
@@ -1497,2 +1650,4 @@ * AddHook | ||
*/ | ||
DOMPurify.addHook = function (entryPoint, hookFunction) { | ||
@@ -1506,3 +1661,2 @@ if (typeof hookFunction !== 'function') { | ||
}; | ||
/** | ||
@@ -1514,9 +1668,11 @@ * RemoveHook | ||
* @param {String} entryPoint entry point for the hook to remove | ||
* @return {Function} removed(popped) hook | ||
*/ | ||
DOMPurify.removeHook = function (entryPoint) { | ||
if (hooks[entryPoint]) { | ||
arrayPop(hooks[entryPoint]); | ||
return arrayPop(hooks[entryPoint]); | ||
} | ||
}; | ||
/** | ||
@@ -1528,2 +1684,4 @@ * RemoveHooks | ||
*/ | ||
DOMPurify.removeHooks = function (entryPoint) { | ||
@@ -1534,3 +1692,2 @@ if (hooks[entryPoint]) { | ||
}; | ||
/** | ||
@@ -1541,2 +1698,4 @@ * RemoveAllHooks | ||
*/ | ||
DOMPurify.removeAllHooks = function () { | ||
@@ -1543,0 +1702,0 @@ hooks = {}; |
@@ -1,5 +0,85 @@ | ||
/*! @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 */ | ||
/*! @license DOMPurify 2.3.7 | (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.7/LICENSE */ | ||
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); } } | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { | ||
return typeof obj; | ||
} : function (obj) { | ||
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}, _typeof(obj); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _construct(Parent, args, Class) { | ||
if (_isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
} else { | ||
_construct = function _construct(Parent, args, Class) { | ||
var a = [null]; | ||
a.push.apply(a, args); | ||
var Constructor = Function.bind.apply(Parent, a); | ||
var instance = new Constructor(); | ||
if (Class) _setPrototypeOf(instance, Class.prototype); | ||
return instance; | ||
}; | ||
} | ||
return _construct.apply(null, arguments); | ||
} | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) return _arrayLikeToArray(arr); | ||
} | ||
function _iterableToArray(iter) { | ||
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
var hasOwnProperty = Object.hasOwnProperty, | ||
@@ -38,3 +118,3 @@ setPrototypeOf = Object.setPrototypeOf, | ||
construct = function construct(Func, args) { | ||
return new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))(); | ||
return _construct(Func, _toConsumableArray(args)); | ||
}; | ||
@@ -46,3 +126,2 @@ } | ||
var arrayPush = unapply(Array.prototype.push); | ||
var stringToLowerCase = unapply(String.prototype.toLowerCase); | ||
@@ -53,10 +132,7 @@ var stringMatch = unapply(String.prototype.match); | ||
var stringTrim = unapply(String.prototype.trim); | ||
var regExpTest = unapply(RegExp.prototype.test); | ||
var typeErrorCreate = unconstruct(TypeError); | ||
function unapply(func) { | ||
return function (thisArg) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
@@ -68,6 +144,5 @@ } | ||
} | ||
function unconstruct(func) { | ||
return function () { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
@@ -79,4 +154,4 @@ } | ||
} | ||
/* Add properties to a lookup table */ | ||
/* Add properties to a lookup table */ | ||
function addToSet(set, array) { | ||
@@ -91,6 +166,9 @@ if (setPrototypeOf) { | ||
var l = array.length; | ||
while (l--) { | ||
var element = array[l]; | ||
if (typeof element === 'string') { | ||
var lcElement = stringToLowerCase(element); | ||
if (lcElement !== element) { | ||
@@ -111,8 +189,8 @@ // Config presets (e.g. tags.js, attrs.js) are immutable. | ||
} | ||
/* Shallow clone an object */ | ||
/* Shallow clone an object */ | ||
function clone(object) { | ||
var newObject = create(null); | ||
var property; | ||
var property = void 0; | ||
for (property in object) { | ||
@@ -126,3 +204,2 @@ if (apply(hasOwnProperty, object, [property])) { | ||
} | ||
/* IE10 doesn't support __lookupGetter__ so lets' | ||
@@ -132,5 +209,7 @@ * simulate it. It also automatically checks | ||
* accordingly. */ | ||
function lookupGetter(object, prop) { | ||
while (object !== null) { | ||
var desc = getOwnPropertyDescriptor(object, prop); | ||
if (desc) { | ||
@@ -157,36 +236,29 @@ if (desc.get) { | ||
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']); | ||
var html$1 = 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']); // SVG | ||
// SVG | ||
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']); | ||
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']); | ||
// List of SVG elements that are disallowed by default. | ||
var svg$1 = 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']); | ||
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']); // List of SVG elements that are disallowed by default. | ||
// We still need to know them so that we can do namespace | ||
// checks properly in case one wants to add them to | ||
// allow-list. | ||
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']); | ||
var mathMl$1 = 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']); // Similarly to SVG, we want to know all MathML elements, | ||
// even those that we disallow by default. | ||
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']); | ||
// Similarly to SVG, we want to know all MathML elements, | ||
// even those that we disallow by default. | ||
var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); | ||
var text = freeze(['#text']); | ||
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']); | ||
var html = 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']); | ||
var svg = 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']); | ||
var mathMl = 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']); | ||
var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); | ||
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']); | ||
var MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode | ||
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']); | ||
var ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm); | ||
var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape | ||
var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); | ||
var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape | ||
// eslint-disable-next-line unicorn/better-regex | ||
var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode | ||
var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm); | ||
var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape | ||
var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape | ||
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 | ||
@@ -199,10 +271,5 @@ ); | ||
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; }; | ||
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); } } | ||
var getGlobal = function getGlobal() { | ||
return typeof window === 'undefined' ? null : window; | ||
}; | ||
/** | ||
@@ -216,12 +283,15 @@ * Creates a no-op policy for internal use only. | ||
*/ | ||
var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) { | ||
if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') { | ||
if (_typeof(trustedTypes) !== 'object' || typeof trustedTypes.createPolicy !== 'function') { | ||
return null; | ||
} | ||
// Allow the callers to control the unique policy name | ||
} // Allow the callers to control the unique policy name | ||
// by adding a data-tt-policy-suffix to the script element with the DOMPurify. | ||
// Policy creation with duplicate names throws in Trusted Types. | ||
var suffix = null; | ||
var ATTR_NAME = 'data-tt-policy-suffix'; | ||
if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) { | ||
@@ -235,4 +305,4 @@ suffix = document.currentScript.getAttribute(ATTR_NAME); | ||
return trustedTypes.createPolicy(policyName, { | ||
createHTML: function createHTML(html$$1) { | ||
return html$$1; | ||
createHTML: function createHTML(html) { | ||
return html; | ||
} | ||
@@ -255,3 +325,2 @@ }); | ||
}; | ||
/** | ||
@@ -261,4 +330,5 @@ * Version label, exposed for easier checks | ||
*/ | ||
DOMPurify.version = '2.3.6'; | ||
DOMPurify.version = '2.3.7'; | ||
/** | ||
@@ -268,2 +338,3 @@ * Array of elements that DOMPurify removed during sanitation. | ||
*/ | ||
DOMPurify.removed = []; | ||
@@ -275,3 +346,2 @@ | ||
DOMPurify.isSupported = false; | ||
return DOMPurify; | ||
@@ -281,3 +351,2 @@ } | ||
var originalDocument = window.document; | ||
var document = window.document; | ||
@@ -290,16 +359,11 @@ var DocumentFragment = window.DocumentFragment, | ||
_window$NamedNodeMap = window.NamedNodeMap, | ||
NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap, | ||
NamedNodeMap = _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap, | ||
HTMLFormElement = window.HTMLFormElement, | ||
DOMParser = window.DOMParser, | ||
trustedTypes = window.trustedTypes; | ||
var ElementPrototype = Element.prototype; | ||
var cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); | ||
var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); | ||
var getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); | ||
var getParentNode = lookupGetter(ElementPrototype, 'parentNode'); | ||
// As per issue #47, the web-components registry is inherited by a | ||
var getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a | ||
// new document created via createHTMLDocument. As per the spec | ||
@@ -310,4 +374,6 @@ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) | ||
// is inherited. | ||
if (typeof HTMLTemplateElement === 'function') { | ||
var template = document.createElement('template'); | ||
if (template.content && template.content.ownerDocument) { | ||
@@ -319,4 +385,4 @@ document = template.content.ownerDocument; | ||
var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument); | ||
var emptyHTML = trustedTypesPolicy ? trustedTypesPolicy.createHTML('') : ''; | ||
var _document = document, | ||
@@ -328,5 +394,4 @@ implementation = _document.implementation, | ||
var importNode = originalDocument.importNode; | ||
var documentMode = {}; | ||
var documentMode = {}; | ||
try { | ||
@@ -337,16 +402,14 @@ documentMode = clone(document).documentMode ? document.documentMode : {}; | ||
var hooks = {}; | ||
/** | ||
* Expose whether this browser supports running the full DOMPurify. | ||
*/ | ||
DOMPurify.isSupported = typeof getParentNode === 'function' && implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9; | ||
var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR, | ||
ERB_EXPR$$1 = ERB_EXPR, | ||
DATA_ATTR$$1 = DATA_ATTR, | ||
ARIA_ATTR$$1 = ARIA_ATTR, | ||
IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA, | ||
ATTR_WHITESPACE$$1 = ATTR_WHITESPACE; | ||
var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI; | ||
var MUSTACHE_EXPR$1 = MUSTACHE_EXPR, | ||
ERB_EXPR$1 = ERB_EXPR, | ||
DATA_ATTR$1 = DATA_ATTR, | ||
ARIA_ATTR$1 = ARIA_ATTR, | ||
IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, | ||
ATTR_WHITESPACE$1 = ATTR_WHITESPACE; | ||
var IS_ALLOWED_URI$1 = IS_ALLOWED_URI; | ||
/** | ||
@@ -360,8 +423,7 @@ * We consider the elements and attributes below to be safe. Ideally | ||
var ALLOWED_TAGS = null; | ||
var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(html), _toConsumableArray$1(svg), _toConsumableArray$1(svgFilters), _toConsumableArray$1(mathMl), _toConsumableArray$1(text))); | ||
var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray(html$1), _toConsumableArray(svg$1), _toConsumableArray(svgFilters), _toConsumableArray(mathMl$1), _toConsumableArray(text))); | ||
/* Allowed attribute names */ | ||
/* Allowed attribute names */ | ||
var ALLOWED_ATTR = null; | ||
var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray$1(html$1), _toConsumableArray$1(svg$1), _toConsumableArray$1(mathMl$1), _toConsumableArray$1(xml))); | ||
var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray(html), _toConsumableArray(svg), _toConsumableArray(mathMl), _toConsumableArray(xml))); | ||
/* | ||
@@ -373,2 +435,3 @@ * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements. | ||
*/ | ||
var CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, { | ||
@@ -394,33 +457,32 @@ tagNameCheck: { | ||
})); | ||
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ | ||
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ | ||
var FORBID_TAGS = null; | ||
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ | ||
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ | ||
var FORBID_ATTR = null; | ||
/* Decide if ARIA attributes are okay */ | ||
/* Decide if ARIA attributes are okay */ | ||
var ALLOW_ARIA_ATTR = true; | ||
/* Decide if custom data attributes are okay */ | ||
/* Decide if custom data attributes are okay */ | ||
var ALLOW_DATA_ATTR = true; | ||
/* Decide if unknown protocols are okay */ | ||
/* Decide if unknown protocols are okay */ | ||
var ALLOW_UNKNOWN_PROTOCOLS = false; | ||
/* Output should be safe for common template engines. | ||
* This means, DOMPurify removes data attributes, mustaches and ERB | ||
*/ | ||
var SAFE_FOR_TEMPLATES = false; | ||
/* Decide if document with <html>... should be returned */ | ||
/* Decide if document with <html>... should be returned */ | ||
var WHOLE_DOCUMENT = false; | ||
/* Track whether config is already set on this instance of DOMPurify. */ | ||
/* Track whether config is already set on this instance of DOMPurify. */ | ||
var SET_CONFIG = false; | ||
/* Decide if all elements (e.g. style, script) must be children of | ||
* document.body. By default, browsers might move them to document.head */ | ||
var FORCE_BODY = false; | ||
/* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html | ||
@@ -430,37 +492,37 @@ * string (or a TrustedHTML object if Trusted Types are supported). | ||
*/ | ||
var RETURN_DOM = false; | ||
/* Decide if a DOM `DocumentFragment` should be returned, instead of a html | ||
* string (or a TrustedHTML object if Trusted Types are supported) */ | ||
var RETURN_DOM_FRAGMENT = false; | ||
/* Try to return a Trusted Type object instead of a string, return a string in | ||
* case Trusted Types are not supported */ | ||
var RETURN_TRUSTED_TYPE = false; | ||
/* Output should be free from DOM clobbering attacks? */ | ||
/* Output should be free from DOM clobbering attacks? */ | ||
var SANITIZE_DOM = true; | ||
/* Keep element content when removing element? */ | ||
/* Keep element content when removing element? */ | ||
var KEEP_CONTENT = true; | ||
/* If a `Node` is passed to sanitize(), then performs sanitization in-place instead | ||
* of importing it into a new Document and returning a sanitized copy */ | ||
var IN_PLACE = false; | ||
/* Allow usage of profiles like html, svg and mathMl */ | ||
/* Allow usage of profiles like html, svg and mathMl */ | ||
var USE_PROFILES = {}; | ||
/* Tags to ignore content of when KEEP_CONTENT is true */ | ||
/* Tags to ignore content of when KEEP_CONTENT is true */ | ||
var FORBID_CONTENTS = null; | ||
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']); | ||
/* Tags that are safe for data: URIs */ | ||
/* Tags that are safe for data: URIs */ | ||
var DATA_URI_TAGS = null; | ||
var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); | ||
/* Attributes safe for values like "javascript:" */ | ||
/* Attributes safe for values like "javascript:" */ | ||
var URI_SAFE_ATTRIBUTES = null; | ||
var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']); | ||
var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; | ||
@@ -470,15 +532,16 @@ var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; | ||
/* Document namespace */ | ||
var NAMESPACE = HTML_NAMESPACE; | ||
var IS_EMPTY_INPUT = false; | ||
/* Parsing of strict XHTML documents */ | ||
/* Parsing of strict XHTML documents */ | ||
var PARSER_MEDIA_TYPE = void 0; | ||
var PARSER_MEDIA_TYPE; | ||
var SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html']; | ||
var DEFAULT_PARSER_MEDIA_TYPE = 'text/html'; | ||
var transformCaseFunc = void 0; | ||
var transformCaseFunc; | ||
/* Keep a reference to config to pass to hooks */ | ||
/* Keep a reference to config to pass to hooks */ | ||
var CONFIG = null; | ||
/* Ideally, do not touch anything below this line */ | ||
/* Ideally, do not touch anything below this line */ | ||
/* ______________________________________________ */ | ||
@@ -491,3 +554,2 @@ | ||
}; | ||
/** | ||
@@ -499,2 +561,4 @@ * _parseConfig | ||
// eslint-disable-next-line complexity | ||
var _parseConfig = function _parseConfig(cfg) { | ||
@@ -504,12 +568,14 @@ if (CONFIG && CONFIG === cfg) { | ||
} | ||
/* Shield configuration object from tampering */ | ||
/* Shield configuration object from tampering */ | ||
if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') { | ||
if (!cfg || _typeof(cfg) !== 'object') { | ||
cfg = {}; | ||
} | ||
/* Shield configuration object from prototype pollution */ | ||
/* Shield configuration object from prototype pollution */ | ||
cfg = clone(cfg); | ||
/* Set configuration parameters */ | ||
/* Set configuration parameters */ | ||
ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS; | ||
@@ -524,15 +590,28 @@ ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR; | ||
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true | ||
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true | ||
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false | ||
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false | ||
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false | ||
RETURN_DOM = cfg.RETURN_DOM || false; // Default false | ||
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false | ||
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false | ||
FORCE_BODY = cfg.FORCE_BODY || false; // Default false | ||
SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true | ||
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true | ||
IN_PLACE = cfg.IN_PLACE || false; // Default false | ||
IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1; | ||
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$1; | ||
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE; | ||
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) { | ||
@@ -550,7 +629,5 @@ CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck; | ||
PARSER_MEDIA_TYPE = | ||
// eslint-disable-next-line unicorn/prefer-includes | ||
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; | ||
PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes | ||
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. | ||
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. | ||
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? function (x) { | ||
@@ -567,15 +644,17 @@ return x; | ||
} | ||
/* Parse profile info */ | ||
/* Parse profile info */ | ||
if (USE_PROFILES) { | ||
ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(text))); | ||
ALLOWED_TAGS = addToSet({}, _toConsumableArray(text)); | ||
ALLOWED_ATTR = []; | ||
if (USE_PROFILES.html === true) { | ||
addToSet(ALLOWED_TAGS, html); | ||
addToSet(ALLOWED_ATTR, html$1); | ||
addToSet(ALLOWED_TAGS, html$1); | ||
addToSet(ALLOWED_ATTR, html); | ||
} | ||
if (USE_PROFILES.svg === true) { | ||
addToSet(ALLOWED_TAGS, svg); | ||
addToSet(ALLOWED_ATTR, svg$1); | ||
addToSet(ALLOWED_TAGS, svg$1); | ||
addToSet(ALLOWED_ATTR, svg); | ||
addToSet(ALLOWED_ATTR, xml); | ||
@@ -586,3 +665,3 @@ } | ||
addToSet(ALLOWED_TAGS, svgFilters); | ||
addToSet(ALLOWED_ATTR, svg$1); | ||
addToSet(ALLOWED_ATTR, svg); | ||
addToSet(ALLOWED_ATTR, xml); | ||
@@ -592,9 +671,10 @@ } | ||
if (USE_PROFILES.mathMl === true) { | ||
addToSet(ALLOWED_TAGS, mathMl); | ||
addToSet(ALLOWED_ATTR, mathMl$1); | ||
addToSet(ALLOWED_TAGS, mathMl$1); | ||
addToSet(ALLOWED_ATTR, mathMl); | ||
addToSet(ALLOWED_ATTR, xml); | ||
} | ||
} | ||
/* Merge configuration parameters */ | ||
/* Merge configuration parameters */ | ||
if (cfg.ADD_TAGS) { | ||
@@ -627,21 +707,24 @@ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { | ||
} | ||
/* Add #text in case KEEP_CONTENT is set to true */ | ||
/* Add #text in case KEEP_CONTENT is set to true */ | ||
if (KEEP_CONTENT) { | ||
ALLOWED_TAGS['#text'] = true; | ||
} | ||
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ | ||
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ | ||
if (WHOLE_DOCUMENT) { | ||
addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); | ||
} | ||
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ | ||
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ | ||
if (ALLOWED_TAGS.table) { | ||
addToSet(ALLOWED_TAGS, ['tbody']); | ||
delete FORBID_TAGS.tbody; | ||
} | ||
} // Prevent further manipulation of configuration. | ||
// Not available in IE8, Safari 5, etc. | ||
// Prevent further manipulation of configuration. | ||
// Not available in IE8, Safari 5, etc. | ||
if (freeze) { | ||
@@ -655,15 +738,17 @@ freeze(cfg); | ||
var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); | ||
var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); // Certain elements are allowed in both SVG and HTML | ||
// namespace. We need to specify them explicitly | ||
// so that they don't get erroneously deleted from | ||
// HTML namespace. | ||
var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); | ||
var COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']); | ||
/* Keep track of all possible SVG and MathML tags | ||
* so that we can perform the namespace checks | ||
* correctly. */ | ||
var ALL_SVG_TAGS = addToSet({}, svg); | ||
var ALL_SVG_TAGS = addToSet({}, svg$1); | ||
addToSet(ALL_SVG_TAGS, svgFilters); | ||
addToSet(ALL_SVG_TAGS, svgDisallowed); | ||
var ALL_MATHML_TAGS = addToSet({}, mathMl); | ||
var ALL_MATHML_TAGS = addToSet({}, mathMl$1); | ||
addToSet(ALL_MATHML_TAGS, mathMlDisallowed); | ||
/** | ||
@@ -677,7 +762,7 @@ * | ||
*/ | ||
var _checkValidNamespace = function _checkValidNamespace(element) { | ||
var parent = getParentNode(element); | ||
var parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode | ||
// can be null. We just simulate parent in this case. | ||
// In JSDOM, if we're inside shadow DOM, then parentNode | ||
// can be null. We just simulate parent in this case. | ||
if (!parent || !parent.tagName) { | ||
@@ -699,13 +784,13 @@ parent = { | ||
return tagName === 'svg'; | ||
} | ||
// The only way to switch from MathML to SVG is via | ||
} // The only way to switch from MathML to SVG is via | ||
// svg if parent is either <annotation-xml> or MathML | ||
// text integration points. | ||
if (parent.namespaceURI === MATHML_NAMESPACE) { | ||
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); | ||
} | ||
} // We only allow elements that are defined in SVG | ||
// spec. All others are disallowed in SVG namespace. | ||
// We only allow elements that are defined in SVG | ||
// spec. All others are disallowed in SVG namespace. | ||
return Boolean(ALL_SVG_TAGS[tagName]); | ||
@@ -720,12 +805,12 @@ } | ||
return tagName === 'math'; | ||
} | ||
} // The only way to switch from SVG to MathML is via | ||
// <math> and HTML integration points | ||
// The only way to switch from SVG to MathML is via | ||
// <math> and HTML integration points | ||
if (parent.namespaceURI === SVG_NAMESPACE) { | ||
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; | ||
} | ||
} // We only allow elements that are defined in MathML | ||
// spec. All others are disallowed in MathML namespace. | ||
// We only allow elements that are defined in MathML | ||
// spec. All others are disallowed in MathML namespace. | ||
return Boolean(ALL_MATHML_TAGS[tagName]); | ||
@@ -744,21 +829,14 @@ } | ||
return false; | ||
} | ||
} // We disallow tags that are specific for MathML | ||
// or SVG and should never appear in HTML namespace | ||
// Certain elements are allowed in both SVG and HTML | ||
// namespace. We need to specify them explicitly | ||
// so that they don't get erronously deleted from | ||
// HTML namespace. | ||
var commonSvgAndHTMLElements = addToSet({}, ['title', 'style', 'font', 'a', 'script']); | ||
// We disallow tags that are specific for MathML | ||
// or SVG and should never appear in HTML namespace | ||
return !ALL_MATHML_TAGS[tagName] && (commonSvgAndHTMLElements[tagName] || !ALL_SVG_TAGS[tagName]); | ||
} | ||
// The code should never reach this place (this means | ||
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]); | ||
} // The code should never reach this place (this means | ||
// that the element somehow got namespace that is not | ||
// HTML, SVG or MathML). Return false just in case. | ||
return false; | ||
}; | ||
/** | ||
@@ -769,4 +847,9 @@ * _forceRemove | ||
*/ | ||
var _forceRemove = function _forceRemove(node) { | ||
arrayPush(DOMPurify.removed, { element: node }); | ||
arrayPush(DOMPurify.removed, { | ||
element: node | ||
}); | ||
try { | ||
@@ -783,3 +866,2 @@ // eslint-disable-next-line unicorn/prefer-dom-node-remove | ||
}; | ||
/** | ||
@@ -791,2 +873,4 @@ * _removeAttribute | ||
*/ | ||
var _removeAttribute = function _removeAttribute(name, node) { | ||
@@ -805,5 +889,4 @@ try { | ||
node.removeAttribute(name); | ||
node.removeAttribute(name); // We void attribute values for unremovable "is"" attributes | ||
// We void attribute values for unremovable "is"" attributes | ||
if (name === 'is' && !ALLOWED_ATTR[name]) { | ||
@@ -821,3 +904,2 @@ if (RETURN_DOM || RETURN_DOM_FRAGMENT) { | ||
}; | ||
/** | ||
@@ -829,6 +911,8 @@ * _initDocument | ||
*/ | ||
var _initDocument = function _initDocument(dirty) { | ||
/* Create a HTML document */ | ||
var doc = void 0; | ||
var leadingWhitespace = void 0; | ||
var doc; | ||
var leadingWhitespace; | ||
@@ -853,2 +937,3 @@ if (FORCE_BODY) { | ||
*/ | ||
if (NAMESPACE === HTML_NAMESPACE) { | ||
@@ -859,10 +944,11 @@ try { | ||
} | ||
/* Use createHTMLDocument in case DOMParser is not available */ | ||
/* Use createHTMLDocument in case DOMParser is not available */ | ||
if (!doc || !doc.documentElement) { | ||
doc = implementation.createDocument(NAMESPACE, 'template', null); | ||
try { | ||
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? '' : dirtyPayload; | ||
} catch (_) { | ||
// Syntax error if dirtyPayload is invalid xml | ||
} catch (_) {// Syntax error if dirtyPayload is invalid xml | ||
} | ||
@@ -876,4 +962,5 @@ } | ||
} | ||
/* Work on whole document or just its body */ | ||
/* Work on whole document or just its body */ | ||
if (NAMESPACE === HTML_NAMESPACE) { | ||
@@ -885,3 +972,2 @@ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; | ||
}; | ||
/** | ||
@@ -893,8 +979,8 @@ * _createIterator | ||
*/ | ||
var _createIterator = function _createIterator(root) { | ||
return createNodeIterator.call(root.ownerDocument || root, root, | ||
// eslint-disable-next-line no-bitwise | ||
return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise | ||
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false); | ||
}; | ||
/** | ||
@@ -906,6 +992,7 @@ * _isClobbered | ||
*/ | ||
var _isClobbered = function _isClobbered(elm) { | ||
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'); | ||
}; | ||
/** | ||
@@ -917,6 +1004,7 @@ * _isNode | ||
*/ | ||
var _isNode = function _isNode(object) { | ||
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'; | ||
return _typeof(Node) === 'object' ? object instanceof Node : object && _typeof(object) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'; | ||
}; | ||
/** | ||
@@ -930,2 +1018,4 @@ * _executeHook | ||
*/ | ||
var _executeHook = function _executeHook(entryPoint, currentNode, data) { | ||
@@ -940,3 +1030,2 @@ if (!hooks[entryPoint]) { | ||
}; | ||
/** | ||
@@ -952,24 +1041,31 @@ * _sanitizeElements | ||
*/ | ||
var _sanitizeElements = function _sanitizeElements(currentNode) { | ||
var content = void 0; | ||
var content; | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('beforeSanitizeElements', currentNode, null); | ||
/* Check if element is clobbered or can clobber */ | ||
/* Check if element is clobbered or can clobber */ | ||
if (_isClobbered(currentNode)) { | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Check if tagname contains Unicode */ | ||
/* Check if tagname contains Unicode */ | ||
if (stringMatch(currentNode.nodeName, /[\u0080-\uFFFF]/)) { | ||
if (regExpTest(/[\u0080-\uFFFF]/, currentNode.nodeName)) { | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Now let's check the element's type and name */ | ||
/* Now let's check the element's type and name */ | ||
var tagName = transformCaseFunc(currentNode.nodeName); | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('uponSanitizeElement', currentNode, { | ||
@@ -979,16 +1075,21 @@ tagName: tagName, | ||
}); | ||
/* Detect mXSS attempts abusing namespace confusion */ | ||
/* Detect mXSS attempts abusing namespace confusion */ | ||
if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { | ||
if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Mitigate a problem with templates inside select */ | ||
/* Mitigate a problem with templates inside select */ | ||
if (tagName === 'select' && regExpTest(/<template/i, currentNode.innerHTML)) { | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Remove element if anything forbids its presence */ | ||
/* Remove element if anything forbids its presence */ | ||
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { | ||
@@ -1000,4 +1101,5 @@ /* Check if we have a custom element to handle */ | ||
} | ||
/* Keep content except for bad-listed elements */ | ||
/* Keep content except for bad-listed elements */ | ||
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { | ||
@@ -1017,8 +1119,11 @@ var parentNode = getParentNode(currentNode) || currentNode.parentNode; | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Check whether element has a valid namespace */ | ||
/* Check whether element has a valid namespace */ | ||
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { | ||
_forceRemove(currentNode); | ||
return true; | ||
@@ -1029,18 +1134,24 @@ } | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Sanitize element content to be template-safe */ | ||
/* Sanitize element content to be template-safe */ | ||
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) { | ||
/* Get the element's text content */ | ||
content = currentNode.textContent; | ||
content = stringReplace(content, MUSTACHE_EXPR$$1, ' '); | ||
content = stringReplace(content, ERB_EXPR$$1, ' '); | ||
content = stringReplace(content, MUSTACHE_EXPR$1, ' '); | ||
content = stringReplace(content, ERB_EXPR$1, ' '); | ||
if (currentNode.textContent !== content) { | ||
arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() }); | ||
arrayPush(DOMPurify.removed, { | ||
element: currentNode.cloneNode() | ||
}); | ||
currentNode.textContent = content; | ||
} | ||
} | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('afterSanitizeElements', currentNode, null); | ||
@@ -1050,3 +1161,2 @@ | ||
}; | ||
/** | ||
@@ -1061,2 +1171,4 @@ * _isValidAttribute | ||
// eslint-disable-next-line complexity | ||
var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) { | ||
@@ -1067,3 +1179,2 @@ /* Make sure attribute cannot clobber */ | ||
} | ||
/* Allow valid data-* attributes: At least one character after "-" | ||
@@ -1073,9 +1184,9 @@ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) | ||
We don't need to check the value; it's always URI safe. */ | ||
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]) { | ||
if ( | ||
// First condition does a very basic check if a) it's basically a valid custom element tagname AND | ||
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]) { | ||
if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND | ||
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck | ||
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck | ||
_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)) || | ||
// Alternative, second condition checks if it's an `is`-attribute, AND | ||
_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)) || // Alternative, second condition checks if it's an `is`-attribute, AND | ||
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck | ||
@@ -1086,3 +1197,4 @@ 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 { | ||
/* Check value is safe. First, is attr inert? If so, is safe */ | ||
} 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 { | ||
} 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 { | ||
return false; | ||
@@ -1093,3 +1205,2 @@ } | ||
}; | ||
/** | ||
@@ -1101,6 +1212,7 @@ * _basicCustomElementCheck | ||
*/ | ||
var _basicCustomElementTest = function _basicCustomElementTest(tagName) { | ||
return tagName.indexOf('-') > 0; | ||
}; | ||
/** | ||
@@ -1116,12 +1228,14 @@ * _sanitizeAttributes | ||
*/ | ||
var _sanitizeAttributes = function _sanitizeAttributes(currentNode) { | ||
var attr = void 0; | ||
var value = void 0; | ||
var lcName = void 0; | ||
var l = void 0; | ||
var attr; | ||
var value; | ||
var lcName; | ||
var l; | ||
/* Execute a hook if present */ | ||
_executeHook('beforeSanitizeAttributes', currentNode, null); | ||
var attributes = currentNode.attributes; | ||
/* Check if we have attributes; if not we might have a text node */ | ||
@@ -1140,4 +1254,4 @@ | ||
l = attributes.length; | ||
/* Go backwards over all attributes; safely remove bad ones */ | ||
/* Go backwards over all attributes; safely remove bad ones */ | ||
while (l--) { | ||
@@ -1148,7 +1262,6 @@ attr = attributes[l]; | ||
namespaceURI = _attr.namespaceURI; | ||
value = stringTrim(attr.value); | ||
value = name === 'value' ? attr.value : stringTrim(attr.value); | ||
lcName = transformCaseFunc(name); | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
hookEvent.attrName = lcName; | ||
@@ -1158,36 +1271,47 @@ hookEvent.attrValue = value; | ||
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set | ||
_executeHook('uponSanitizeAttribute', currentNode, hookEvent); | ||
value = hookEvent.attrValue; | ||
/* Did the hooks approve of the attribute? */ | ||
if (hookEvent.forceKeepAttr) { | ||
continue; | ||
} | ||
/* Remove attribute */ | ||
/* Remove attribute */ | ||
_removeAttribute(name, currentNode); | ||
/* Did the hooks approve of the attribute? */ | ||
/* Did the hooks approve of the attribute? */ | ||
if (!hookEvent.keepAttr) { | ||
continue; | ||
} | ||
/* Work around a security issue in jQuery 3.0 */ | ||
/* Work around a security issue in jQuery 3.0 */ | ||
if (regExpTest(/\/>/i, value)) { | ||
_removeAttribute(name, currentNode); | ||
continue; | ||
} | ||
/* Sanitize attribute content to be template-safe */ | ||
/* Sanitize attribute content to be template-safe */ | ||
if (SAFE_FOR_TEMPLATES) { | ||
value = stringReplace(value, MUSTACHE_EXPR$$1, ' '); | ||
value = stringReplace(value, ERB_EXPR$$1, ' '); | ||
value = stringReplace(value, MUSTACHE_EXPR$1, ' '); | ||
value = stringReplace(value, ERB_EXPR$1, ' '); | ||
} | ||
/* Is `value` valid for this attribute? */ | ||
/* Is `value` valid for this attribute? */ | ||
var lcTag = transformCaseFunc(currentNode.nodeName); | ||
if (!_isValidAttribute(lcTag, lcName, value)) { | ||
continue; | ||
} | ||
/* Handle invalid data-* attribute set by try-catching it */ | ||
/* Handle invalid data-* attribute set by try-catching it */ | ||
try { | ||
@@ -1204,7 +1328,7 @@ if (namespaceURI) { | ||
} | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('afterSanitizeAttributes', currentNode, null); | ||
}; | ||
/** | ||
@@ -1215,7 +1339,11 @@ * _sanitizeShadowDOM | ||
*/ | ||
var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) { | ||
var shadowNode = void 0; | ||
var shadowNode; | ||
var shadowIterator = _createIterator(fragment); | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('beforeSanitizeShadowDOM', fragment, null); | ||
@@ -1226,21 +1354,24 @@ | ||
_executeHook('uponSanitizeShadowNode', shadowNode, null); | ||
/* Sanitize tags and elements */ | ||
/* Sanitize tags and elements */ | ||
if (_sanitizeElements(shadowNode)) { | ||
continue; | ||
} | ||
/* Deep shadow DOM detected */ | ||
/* Deep shadow DOM detected */ | ||
if (shadowNode.content instanceof DocumentFragment) { | ||
_sanitizeShadowDOM(shadowNode.content); | ||
} | ||
/* Check attributes, sanitize if necessary */ | ||
/* Check attributes, sanitize if necessary */ | ||
_sanitizeAttributes(shadowNode); | ||
} | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('afterSanitizeShadowDOM', fragment, null); | ||
}; | ||
/** | ||
@@ -1254,17 +1385,22 @@ * Sanitize | ||
// eslint-disable-next-line complexity | ||
DOMPurify.sanitize = function (dirty, cfg) { | ||
var body = void 0; | ||
var importedNode = void 0; | ||
var currentNode = void 0; | ||
var oldNode = void 0; | ||
var returnNode = void 0; | ||
var body; | ||
var importedNode; | ||
var currentNode; | ||
var oldNode; | ||
var returnNode; | ||
/* Make sure we have a string to sanitize. | ||
DO NOT return early, as this will return the wrong type if | ||
the user has requested a DOM object rather than a string */ | ||
IS_EMPTY_INPUT = !dirty; | ||
if (IS_EMPTY_INPUT) { | ||
dirty = '<!-->'; | ||
} | ||
/* Stringify, in case dirty is an object */ | ||
/* Stringify, in case dirty is an object */ | ||
if (typeof dirty !== 'string' && !_isNode(dirty)) { | ||
@@ -1276,2 +1412,3 @@ // eslint-disable-next-line no-negated-condition | ||
dirty = dirty.toString(); | ||
if (typeof dirty !== 'string') { | ||
@@ -1282,4 +1419,5 @@ throw typeErrorCreate('dirty is not a string, aborting'); | ||
} | ||
/* Check we can run. Otherwise fall back or ignore */ | ||
/* Check we can run. Otherwise fall back or ignore */ | ||
if (!DOMPurify.isSupported) { | ||
@@ -1298,12 +1436,14 @@ if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') { | ||
} | ||
/* Assign config vars */ | ||
/* Assign config vars */ | ||
if (!SET_CONFIG) { | ||
_parseConfig(cfg); | ||
} | ||
/* Clean up removed elements */ | ||
/* Clean up removed elements */ | ||
DOMPurify.removed = []; | ||
/* Check if dirty is correctly typed for IN_PLACE */ | ||
/* Check if dirty is correctly typed for IN_PLACE */ | ||
if (typeof dirty === 'string') { | ||
@@ -1317,2 +1457,3 @@ IN_PLACE = false; | ||
var tagName = transformCaseFunc(dirty.nodeName); | ||
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { | ||
@@ -1327,2 +1468,3 @@ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place'); | ||
importedNode = body.ownerDocument.importNode(dirty, true); | ||
if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') { | ||
@@ -1339,12 +1481,12 @@ /* Node is already a body, use as is */ | ||
/* Exit directly if we have nothing to do */ | ||
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && | ||
// eslint-disable-next-line unicorn/prefer-includes | ||
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes | ||
dirty.indexOf('<') === -1) { | ||
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; | ||
} | ||
/* Initialize the document to work on */ | ||
/* Initialize the document to work on */ | ||
body = _initDocument(dirty); | ||
/* Check we have a DOM node from the data */ | ||
/* Check we have a DOM node from the data */ | ||
if (!body) { | ||
@@ -1354,12 +1496,15 @@ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : ''; | ||
} | ||
/* Remove first element node (ours) if FORCE_BODY is set */ | ||
/* Remove first element node (ours) if FORCE_BODY is set */ | ||
if (body && FORCE_BODY) { | ||
_forceRemove(body.firstChild); | ||
} | ||
/* Get node iterator */ | ||
/* Get node iterator */ | ||
var nodeIterator = _createIterator(IN_PLACE ? dirty : body); | ||
/* Now start iterating over the created document */ | ||
/* Now start iterating over the created document */ | ||
while (currentNode = nodeIterator.nextNode()) { | ||
@@ -1370,14 +1515,17 @@ /* Fix IE's strange behavior with manipulated textNodes #89 */ | ||
} | ||
/* Sanitize tags and elements */ | ||
/* Sanitize tags and elements */ | ||
if (_sanitizeElements(currentNode)) { | ||
continue; | ||
} | ||
/* Shadow DOM detected, sanitize it */ | ||
/* Shadow DOM detected, sanitize it */ | ||
if (currentNode.content instanceof DocumentFragment) { | ||
_sanitizeShadowDOM(currentNode.content); | ||
} | ||
/* Check attributes, sanitize if necessary */ | ||
/* Check attributes, sanitize if necessary */ | ||
_sanitizeAttributes(currentNode); | ||
@@ -1389,9 +1537,10 @@ | ||
oldNode = null; | ||
/* If we sanitized `dirty` in-place, return it. */ | ||
/* If we sanitized `dirty` in-place, return it. */ | ||
if (IN_PLACE) { | ||
return dirty; | ||
} | ||
/* Return sanitized string or DOM */ | ||
/* Return sanitized string or DOM */ | ||
if (RETURN_DOM) { | ||
@@ -1424,12 +1573,13 @@ if (RETURN_DOM_FRAGMENT) { | ||
var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; | ||
/* Serialize doctype if allowed */ | ||
/* Serialize doctype if allowed */ | ||
if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) { | ||
serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML; | ||
} | ||
/* Sanitize final string template-safe */ | ||
/* Sanitize final string template-safe */ | ||
if (SAFE_FOR_TEMPLATES) { | ||
serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$$1, ' '); | ||
serializedHTML = stringReplace(serializedHTML, ERB_EXPR$$1, ' '); | ||
serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$1, ' '); | ||
serializedHTML = stringReplace(serializedHTML, ERB_EXPR$1, ' '); | ||
} | ||
@@ -1439,3 +1589,2 @@ | ||
}; | ||
/** | ||
@@ -1447,7 +1596,9 @@ * Public method to set the configuration once | ||
*/ | ||
DOMPurify.setConfig = function (cfg) { | ||
_parseConfig(cfg); | ||
SET_CONFIG = true; | ||
}; | ||
/** | ||
@@ -1458,2 +1609,4 @@ * Public method to remove the configuration | ||
*/ | ||
DOMPurify.clearConfig = function () { | ||
@@ -1463,3 +1616,2 @@ CONFIG = null; | ||
}; | ||
/** | ||
@@ -1475,2 +1627,4 @@ * Public method to check if an attribute value is valid. | ||
*/ | ||
DOMPurify.isValidAttribute = function (tag, attr, value) { | ||
@@ -1486,3 +1640,2 @@ /* Initialize shared config vars if necessary. */ | ||
}; | ||
/** | ||
@@ -1495,2 +1648,4 @@ * AddHook | ||
*/ | ||
DOMPurify.addHook = function (entryPoint, hookFunction) { | ||
@@ -1504,3 +1659,2 @@ if (typeof hookFunction !== 'function') { | ||
}; | ||
/** | ||
@@ -1512,9 +1666,11 @@ * RemoveHook | ||
* @param {String} entryPoint entry point for the hook to remove | ||
* @return {Function} removed(popped) hook | ||
*/ | ||
DOMPurify.removeHook = function (entryPoint) { | ||
if (hooks[entryPoint]) { | ||
arrayPop(hooks[entryPoint]); | ||
return arrayPop(hooks[entryPoint]); | ||
} | ||
}; | ||
/** | ||
@@ -1526,2 +1682,4 @@ * RemoveHooks | ||
*/ | ||
DOMPurify.removeHooks = function (entryPoint) { | ||
@@ -1532,3 +1690,2 @@ if (hooks[entryPoint]) { | ||
}; | ||
/** | ||
@@ -1539,2 +1696,4 @@ * RemoveAllHooks | ||
*/ | ||
DOMPurify.removeAllHooks = function () { | ||
@@ -1549,3 +1708,3 @@ hooks = {}; | ||
export default purify; | ||
export { purify as default }; | ||
//# sourceMappingURL=purify.es.js.map |
@@ -1,2 +0,2 @@ | ||
/*! @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 */ | ||
/*! @license DOMPurify 2.3.7 | (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.7/LICENSE */ | ||
@@ -6,7 +6,87 @@ (function (global, factory) { | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = global || self, global.DOMPurify = factory()); | ||
}(this, function () { 'use strict'; | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.DOMPurify = factory()); | ||
})(this, (function () { 'use strict'; | ||
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); } } | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { | ||
return typeof obj; | ||
} : function (obj) { | ||
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}, _typeof(obj); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _construct(Parent, args, Class) { | ||
if (_isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
} else { | ||
_construct = function _construct(Parent, args, Class) { | ||
var a = [null]; | ||
a.push.apply(a, args); | ||
var Constructor = Function.bind.apply(Parent, a); | ||
var instance = new Constructor(); | ||
if (Class) _setPrototypeOf(instance, Class.prototype); | ||
return instance; | ||
}; | ||
} | ||
return _construct.apply(null, arguments); | ||
} | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) return _arrayLikeToArray(arr); | ||
} | ||
function _iterableToArray(iter) { | ||
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
var hasOwnProperty = Object.hasOwnProperty, | ||
@@ -45,3 +125,3 @@ setPrototypeOf = Object.setPrototypeOf, | ||
construct = function construct(Func, args) { | ||
return new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))(); | ||
return _construct(Func, _toConsumableArray(args)); | ||
}; | ||
@@ -53,3 +133,2 @@ } | ||
var arrayPush = unapply(Array.prototype.push); | ||
var stringToLowerCase = unapply(String.prototype.toLowerCase); | ||
@@ -60,10 +139,7 @@ var stringMatch = unapply(String.prototype.match); | ||
var stringTrim = unapply(String.prototype.trim); | ||
var regExpTest = unapply(RegExp.prototype.test); | ||
var typeErrorCreate = unconstruct(TypeError); | ||
function unapply(func) { | ||
return function (thisArg) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
@@ -75,6 +151,5 @@ } | ||
} | ||
function unconstruct(func) { | ||
return function () { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
@@ -86,4 +161,4 @@ } | ||
} | ||
/* Add properties to a lookup table */ | ||
/* Add properties to a lookup table */ | ||
function addToSet(set, array) { | ||
@@ -98,6 +173,9 @@ if (setPrototypeOf) { | ||
var l = array.length; | ||
while (l--) { | ||
var element = array[l]; | ||
if (typeof element === 'string') { | ||
var lcElement = stringToLowerCase(element); | ||
if (lcElement !== element) { | ||
@@ -118,8 +196,8 @@ // Config presets (e.g. tags.js, attrs.js) are immutable. | ||
} | ||
/* Shallow clone an object */ | ||
/* Shallow clone an object */ | ||
function clone(object) { | ||
var newObject = create(null); | ||
var property; | ||
var property = void 0; | ||
for (property in object) { | ||
@@ -133,3 +211,2 @@ if (apply(hasOwnProperty, object, [property])) { | ||
} | ||
/* IE10 doesn't support __lookupGetter__ so lets' | ||
@@ -139,5 +216,7 @@ * simulate it. It also automatically checks | ||
* accordingly. */ | ||
function lookupGetter(object, prop) { | ||
while (object !== null) { | ||
var desc = getOwnPropertyDescriptor(object, prop); | ||
if (desc) { | ||
@@ -164,36 +243,29 @@ if (desc.get) { | ||
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']); | ||
var html$1 = 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']); // SVG | ||
// SVG | ||
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']); | ||
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']); | ||
// List of SVG elements that are disallowed by default. | ||
var svg$1 = 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']); | ||
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']); // List of SVG elements that are disallowed by default. | ||
// We still need to know them so that we can do namespace | ||
// checks properly in case one wants to add them to | ||
// allow-list. | ||
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']); | ||
var mathMl$1 = 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']); // Similarly to SVG, we want to know all MathML elements, | ||
// even those that we disallow by default. | ||
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']); | ||
// Similarly to SVG, we want to know all MathML elements, | ||
// even those that we disallow by default. | ||
var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); | ||
var text = freeze(['#text']); | ||
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']); | ||
var html = 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']); | ||
var svg = 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']); | ||
var mathMl = 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']); | ||
var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); | ||
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']); | ||
var MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode | ||
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']); | ||
var ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm); | ||
var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape | ||
var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); | ||
var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape | ||
// eslint-disable-next-line unicorn/better-regex | ||
var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode | ||
var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm); | ||
var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape | ||
var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape | ||
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 | ||
@@ -206,10 +278,5 @@ ); | ||
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; }; | ||
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); } } | ||
var getGlobal = function getGlobal() { | ||
return typeof window === 'undefined' ? null : window; | ||
}; | ||
/** | ||
@@ -223,12 +290,15 @@ * Creates a no-op policy for internal use only. | ||
*/ | ||
var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) { | ||
if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') { | ||
if (_typeof(trustedTypes) !== 'object' || typeof trustedTypes.createPolicy !== 'function') { | ||
return null; | ||
} | ||
// Allow the callers to control the unique policy name | ||
} // Allow the callers to control the unique policy name | ||
// by adding a data-tt-policy-suffix to the script element with the DOMPurify. | ||
// Policy creation with duplicate names throws in Trusted Types. | ||
var suffix = null; | ||
var ATTR_NAME = 'data-tt-policy-suffix'; | ||
if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) { | ||
@@ -242,4 +312,4 @@ suffix = document.currentScript.getAttribute(ATTR_NAME); | ||
return trustedTypes.createPolicy(policyName, { | ||
createHTML: function createHTML(html$$1) { | ||
return html$$1; | ||
createHTML: function createHTML(html) { | ||
return html; | ||
} | ||
@@ -262,3 +332,2 @@ }); | ||
}; | ||
/** | ||
@@ -268,4 +337,5 @@ * Version label, exposed for easier checks | ||
*/ | ||
DOMPurify.version = '2.3.6'; | ||
DOMPurify.version = '2.3.7'; | ||
/** | ||
@@ -275,2 +345,3 @@ * Array of elements that DOMPurify removed during sanitation. | ||
*/ | ||
DOMPurify.removed = []; | ||
@@ -282,3 +353,2 @@ | ||
DOMPurify.isSupported = false; | ||
return DOMPurify; | ||
@@ -288,3 +358,2 @@ } | ||
var originalDocument = window.document; | ||
var document = window.document; | ||
@@ -297,16 +366,11 @@ var DocumentFragment = window.DocumentFragment, | ||
_window$NamedNodeMap = window.NamedNodeMap, | ||
NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap, | ||
NamedNodeMap = _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap, | ||
HTMLFormElement = window.HTMLFormElement, | ||
DOMParser = window.DOMParser, | ||
trustedTypes = window.trustedTypes; | ||
var ElementPrototype = Element.prototype; | ||
var cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); | ||
var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); | ||
var getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); | ||
var getParentNode = lookupGetter(ElementPrototype, 'parentNode'); | ||
// As per issue #47, the web-components registry is inherited by a | ||
var getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a | ||
// new document created via createHTMLDocument. As per the spec | ||
@@ -317,4 +381,6 @@ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) | ||
// is inherited. | ||
if (typeof HTMLTemplateElement === 'function') { | ||
var template = document.createElement('template'); | ||
if (template.content && template.content.ownerDocument) { | ||
@@ -326,4 +392,4 @@ document = template.content.ownerDocument; | ||
var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument); | ||
var emptyHTML = trustedTypesPolicy ? trustedTypesPolicy.createHTML('') : ''; | ||
var _document = document, | ||
@@ -335,5 +401,4 @@ implementation = _document.implementation, | ||
var importNode = originalDocument.importNode; | ||
var documentMode = {}; | ||
var documentMode = {}; | ||
try { | ||
@@ -344,16 +409,14 @@ documentMode = clone(document).documentMode ? document.documentMode : {}; | ||
var hooks = {}; | ||
/** | ||
* Expose whether this browser supports running the full DOMPurify. | ||
*/ | ||
DOMPurify.isSupported = typeof getParentNode === 'function' && implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9; | ||
var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR, | ||
ERB_EXPR$$1 = ERB_EXPR, | ||
DATA_ATTR$$1 = DATA_ATTR, | ||
ARIA_ATTR$$1 = ARIA_ATTR, | ||
IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA, | ||
ATTR_WHITESPACE$$1 = ATTR_WHITESPACE; | ||
var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI; | ||
var MUSTACHE_EXPR$1 = MUSTACHE_EXPR, | ||
ERB_EXPR$1 = ERB_EXPR, | ||
DATA_ATTR$1 = DATA_ATTR, | ||
ARIA_ATTR$1 = ARIA_ATTR, | ||
IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, | ||
ATTR_WHITESPACE$1 = ATTR_WHITESPACE; | ||
var IS_ALLOWED_URI$1 = IS_ALLOWED_URI; | ||
/** | ||
@@ -367,8 +430,7 @@ * We consider the elements and attributes below to be safe. Ideally | ||
var ALLOWED_TAGS = null; | ||
var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(html), _toConsumableArray$1(svg), _toConsumableArray$1(svgFilters), _toConsumableArray$1(mathMl), _toConsumableArray$1(text))); | ||
var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray(html$1), _toConsumableArray(svg$1), _toConsumableArray(svgFilters), _toConsumableArray(mathMl$1), _toConsumableArray(text))); | ||
/* Allowed attribute names */ | ||
/* Allowed attribute names */ | ||
var ALLOWED_ATTR = null; | ||
var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray$1(html$1), _toConsumableArray$1(svg$1), _toConsumableArray$1(mathMl$1), _toConsumableArray$1(xml))); | ||
var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray(html), _toConsumableArray(svg), _toConsumableArray(mathMl), _toConsumableArray(xml))); | ||
/* | ||
@@ -380,2 +442,3 @@ * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements. | ||
*/ | ||
var CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, { | ||
@@ -401,33 +464,32 @@ tagNameCheck: { | ||
})); | ||
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ | ||
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ | ||
var FORBID_TAGS = null; | ||
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ | ||
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ | ||
var FORBID_ATTR = null; | ||
/* Decide if ARIA attributes are okay */ | ||
/* Decide if ARIA attributes are okay */ | ||
var ALLOW_ARIA_ATTR = true; | ||
/* Decide if custom data attributes are okay */ | ||
/* Decide if custom data attributes are okay */ | ||
var ALLOW_DATA_ATTR = true; | ||
/* Decide if unknown protocols are okay */ | ||
/* Decide if unknown protocols are okay */ | ||
var ALLOW_UNKNOWN_PROTOCOLS = false; | ||
/* Output should be safe for common template engines. | ||
* This means, DOMPurify removes data attributes, mustaches and ERB | ||
*/ | ||
var SAFE_FOR_TEMPLATES = false; | ||
/* Decide if document with <html>... should be returned */ | ||
/* Decide if document with <html>... should be returned */ | ||
var WHOLE_DOCUMENT = false; | ||
/* Track whether config is already set on this instance of DOMPurify. */ | ||
/* Track whether config is already set on this instance of DOMPurify. */ | ||
var SET_CONFIG = false; | ||
/* Decide if all elements (e.g. style, script) must be children of | ||
* document.body. By default, browsers might move them to document.head */ | ||
var FORCE_BODY = false; | ||
/* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html | ||
@@ -437,37 +499,37 @@ * string (or a TrustedHTML object if Trusted Types are supported). | ||
*/ | ||
var RETURN_DOM = false; | ||
/* Decide if a DOM `DocumentFragment` should be returned, instead of a html | ||
* string (or a TrustedHTML object if Trusted Types are supported) */ | ||
var RETURN_DOM_FRAGMENT = false; | ||
/* Try to return a Trusted Type object instead of a string, return a string in | ||
* case Trusted Types are not supported */ | ||
var RETURN_TRUSTED_TYPE = false; | ||
/* Output should be free from DOM clobbering attacks? */ | ||
/* Output should be free from DOM clobbering attacks? */ | ||
var SANITIZE_DOM = true; | ||
/* Keep element content when removing element? */ | ||
/* Keep element content when removing element? */ | ||
var KEEP_CONTENT = true; | ||
/* If a `Node` is passed to sanitize(), then performs sanitization in-place instead | ||
* of importing it into a new Document and returning a sanitized copy */ | ||
var IN_PLACE = false; | ||
/* Allow usage of profiles like html, svg and mathMl */ | ||
/* Allow usage of profiles like html, svg and mathMl */ | ||
var USE_PROFILES = {}; | ||
/* Tags to ignore content of when KEEP_CONTENT is true */ | ||
/* Tags to ignore content of when KEEP_CONTENT is true */ | ||
var FORBID_CONTENTS = null; | ||
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']); | ||
/* Tags that are safe for data: URIs */ | ||
/* Tags that are safe for data: URIs */ | ||
var DATA_URI_TAGS = null; | ||
var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); | ||
/* Attributes safe for values like "javascript:" */ | ||
/* Attributes safe for values like "javascript:" */ | ||
var URI_SAFE_ATTRIBUTES = null; | ||
var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']); | ||
var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; | ||
@@ -477,15 +539,16 @@ var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; | ||
/* Document namespace */ | ||
var NAMESPACE = HTML_NAMESPACE; | ||
var IS_EMPTY_INPUT = false; | ||
/* Parsing of strict XHTML documents */ | ||
/* Parsing of strict XHTML documents */ | ||
var PARSER_MEDIA_TYPE = void 0; | ||
var PARSER_MEDIA_TYPE; | ||
var SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html']; | ||
var DEFAULT_PARSER_MEDIA_TYPE = 'text/html'; | ||
var transformCaseFunc = void 0; | ||
var transformCaseFunc; | ||
/* Keep a reference to config to pass to hooks */ | ||
/* Keep a reference to config to pass to hooks */ | ||
var CONFIG = null; | ||
/* Ideally, do not touch anything below this line */ | ||
/* Ideally, do not touch anything below this line */ | ||
/* ______________________________________________ */ | ||
@@ -498,3 +561,2 @@ | ||
}; | ||
/** | ||
@@ -506,2 +568,4 @@ * _parseConfig | ||
// eslint-disable-next-line complexity | ||
var _parseConfig = function _parseConfig(cfg) { | ||
@@ -511,12 +575,14 @@ if (CONFIG && CONFIG === cfg) { | ||
} | ||
/* Shield configuration object from tampering */ | ||
/* Shield configuration object from tampering */ | ||
if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') { | ||
if (!cfg || _typeof(cfg) !== 'object') { | ||
cfg = {}; | ||
} | ||
/* Shield configuration object from prototype pollution */ | ||
/* Shield configuration object from prototype pollution */ | ||
cfg = clone(cfg); | ||
/* Set configuration parameters */ | ||
/* Set configuration parameters */ | ||
ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS; | ||
@@ -531,15 +597,28 @@ ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR; | ||
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true | ||
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true | ||
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false | ||
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false | ||
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false | ||
RETURN_DOM = cfg.RETURN_DOM || false; // Default false | ||
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false | ||
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false | ||
FORCE_BODY = cfg.FORCE_BODY || false; // Default false | ||
SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true | ||
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true | ||
IN_PLACE = cfg.IN_PLACE || false; // Default false | ||
IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1; | ||
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$1; | ||
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE; | ||
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) { | ||
@@ -557,7 +636,5 @@ CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck; | ||
PARSER_MEDIA_TYPE = | ||
// eslint-disable-next-line unicorn/prefer-includes | ||
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; | ||
PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes | ||
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. | ||
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. | ||
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? function (x) { | ||
@@ -574,15 +651,17 @@ return x; | ||
} | ||
/* Parse profile info */ | ||
/* Parse profile info */ | ||
if (USE_PROFILES) { | ||
ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(text))); | ||
ALLOWED_TAGS = addToSet({}, _toConsumableArray(text)); | ||
ALLOWED_ATTR = []; | ||
if (USE_PROFILES.html === true) { | ||
addToSet(ALLOWED_TAGS, html); | ||
addToSet(ALLOWED_ATTR, html$1); | ||
addToSet(ALLOWED_TAGS, html$1); | ||
addToSet(ALLOWED_ATTR, html); | ||
} | ||
if (USE_PROFILES.svg === true) { | ||
addToSet(ALLOWED_TAGS, svg); | ||
addToSet(ALLOWED_ATTR, svg$1); | ||
addToSet(ALLOWED_TAGS, svg$1); | ||
addToSet(ALLOWED_ATTR, svg); | ||
addToSet(ALLOWED_ATTR, xml); | ||
@@ -593,3 +672,3 @@ } | ||
addToSet(ALLOWED_TAGS, svgFilters); | ||
addToSet(ALLOWED_ATTR, svg$1); | ||
addToSet(ALLOWED_ATTR, svg); | ||
addToSet(ALLOWED_ATTR, xml); | ||
@@ -599,9 +678,10 @@ } | ||
if (USE_PROFILES.mathMl === true) { | ||
addToSet(ALLOWED_TAGS, mathMl); | ||
addToSet(ALLOWED_ATTR, mathMl$1); | ||
addToSet(ALLOWED_TAGS, mathMl$1); | ||
addToSet(ALLOWED_ATTR, mathMl); | ||
addToSet(ALLOWED_ATTR, xml); | ||
} | ||
} | ||
/* Merge configuration parameters */ | ||
/* Merge configuration parameters */ | ||
if (cfg.ADD_TAGS) { | ||
@@ -634,21 +714,24 @@ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { | ||
} | ||
/* Add #text in case KEEP_CONTENT is set to true */ | ||
/* Add #text in case KEEP_CONTENT is set to true */ | ||
if (KEEP_CONTENT) { | ||
ALLOWED_TAGS['#text'] = true; | ||
} | ||
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ | ||
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ | ||
if (WHOLE_DOCUMENT) { | ||
addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); | ||
} | ||
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ | ||
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ | ||
if (ALLOWED_TAGS.table) { | ||
addToSet(ALLOWED_TAGS, ['tbody']); | ||
delete FORBID_TAGS.tbody; | ||
} | ||
} // Prevent further manipulation of configuration. | ||
// Not available in IE8, Safari 5, etc. | ||
// Prevent further manipulation of configuration. | ||
// Not available in IE8, Safari 5, etc. | ||
if (freeze) { | ||
@@ -662,15 +745,17 @@ freeze(cfg); | ||
var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); | ||
var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); // Certain elements are allowed in both SVG and HTML | ||
// namespace. We need to specify them explicitly | ||
// so that they don't get erroneously deleted from | ||
// HTML namespace. | ||
var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); | ||
var COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']); | ||
/* Keep track of all possible SVG and MathML tags | ||
* so that we can perform the namespace checks | ||
* correctly. */ | ||
var ALL_SVG_TAGS = addToSet({}, svg); | ||
var ALL_SVG_TAGS = addToSet({}, svg$1); | ||
addToSet(ALL_SVG_TAGS, svgFilters); | ||
addToSet(ALL_SVG_TAGS, svgDisallowed); | ||
var ALL_MATHML_TAGS = addToSet({}, mathMl); | ||
var ALL_MATHML_TAGS = addToSet({}, mathMl$1); | ||
addToSet(ALL_MATHML_TAGS, mathMlDisallowed); | ||
/** | ||
@@ -684,7 +769,7 @@ * | ||
*/ | ||
var _checkValidNamespace = function _checkValidNamespace(element) { | ||
var parent = getParentNode(element); | ||
var parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode | ||
// can be null. We just simulate parent in this case. | ||
// In JSDOM, if we're inside shadow DOM, then parentNode | ||
// can be null. We just simulate parent in this case. | ||
if (!parent || !parent.tagName) { | ||
@@ -706,13 +791,13 @@ parent = { | ||
return tagName === 'svg'; | ||
} | ||
// The only way to switch from MathML to SVG is via | ||
} // The only way to switch from MathML to SVG is via | ||
// svg if parent is either <annotation-xml> or MathML | ||
// text integration points. | ||
if (parent.namespaceURI === MATHML_NAMESPACE) { | ||
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); | ||
} | ||
} // We only allow elements that are defined in SVG | ||
// spec. All others are disallowed in SVG namespace. | ||
// We only allow elements that are defined in SVG | ||
// spec. All others are disallowed in SVG namespace. | ||
return Boolean(ALL_SVG_TAGS[tagName]); | ||
@@ -727,12 +812,12 @@ } | ||
return tagName === 'math'; | ||
} | ||
} // The only way to switch from SVG to MathML is via | ||
// <math> and HTML integration points | ||
// The only way to switch from SVG to MathML is via | ||
// <math> and HTML integration points | ||
if (parent.namespaceURI === SVG_NAMESPACE) { | ||
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; | ||
} | ||
} // We only allow elements that are defined in MathML | ||
// spec. All others are disallowed in MathML namespace. | ||
// We only allow elements that are defined in MathML | ||
// spec. All others are disallowed in MathML namespace. | ||
return Boolean(ALL_MATHML_TAGS[tagName]); | ||
@@ -751,21 +836,14 @@ } | ||
return false; | ||
} | ||
} // We disallow tags that are specific for MathML | ||
// or SVG and should never appear in HTML namespace | ||
// Certain elements are allowed in both SVG and HTML | ||
// namespace. We need to specify them explicitly | ||
// so that they don't get erronously deleted from | ||
// HTML namespace. | ||
var commonSvgAndHTMLElements = addToSet({}, ['title', 'style', 'font', 'a', 'script']); | ||
// We disallow tags that are specific for MathML | ||
// or SVG and should never appear in HTML namespace | ||
return !ALL_MATHML_TAGS[tagName] && (commonSvgAndHTMLElements[tagName] || !ALL_SVG_TAGS[tagName]); | ||
} | ||
// The code should never reach this place (this means | ||
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]); | ||
} // The code should never reach this place (this means | ||
// that the element somehow got namespace that is not | ||
// HTML, SVG or MathML). Return false just in case. | ||
return false; | ||
}; | ||
/** | ||
@@ -776,4 +854,9 @@ * _forceRemove | ||
*/ | ||
var _forceRemove = function _forceRemove(node) { | ||
arrayPush(DOMPurify.removed, { element: node }); | ||
arrayPush(DOMPurify.removed, { | ||
element: node | ||
}); | ||
try { | ||
@@ -790,3 +873,2 @@ // eslint-disable-next-line unicorn/prefer-dom-node-remove | ||
}; | ||
/** | ||
@@ -798,2 +880,4 @@ * _removeAttribute | ||
*/ | ||
var _removeAttribute = function _removeAttribute(name, node) { | ||
@@ -812,5 +896,4 @@ try { | ||
node.removeAttribute(name); | ||
node.removeAttribute(name); // We void attribute values for unremovable "is"" attributes | ||
// We void attribute values for unremovable "is"" attributes | ||
if (name === 'is' && !ALLOWED_ATTR[name]) { | ||
@@ -828,3 +911,2 @@ if (RETURN_DOM || RETURN_DOM_FRAGMENT) { | ||
}; | ||
/** | ||
@@ -836,6 +918,8 @@ * _initDocument | ||
*/ | ||
var _initDocument = function _initDocument(dirty) { | ||
/* Create a HTML document */ | ||
var doc = void 0; | ||
var leadingWhitespace = void 0; | ||
var doc; | ||
var leadingWhitespace; | ||
@@ -860,2 +944,3 @@ if (FORCE_BODY) { | ||
*/ | ||
if (NAMESPACE === HTML_NAMESPACE) { | ||
@@ -866,10 +951,11 @@ try { | ||
} | ||
/* Use createHTMLDocument in case DOMParser is not available */ | ||
/* Use createHTMLDocument in case DOMParser is not available */ | ||
if (!doc || !doc.documentElement) { | ||
doc = implementation.createDocument(NAMESPACE, 'template', null); | ||
try { | ||
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? '' : dirtyPayload; | ||
} catch (_) { | ||
// Syntax error if dirtyPayload is invalid xml | ||
} catch (_) {// Syntax error if dirtyPayload is invalid xml | ||
} | ||
@@ -883,4 +969,5 @@ } | ||
} | ||
/* Work on whole document or just its body */ | ||
/* Work on whole document or just its body */ | ||
if (NAMESPACE === HTML_NAMESPACE) { | ||
@@ -892,3 +979,2 @@ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; | ||
}; | ||
/** | ||
@@ -900,8 +986,8 @@ * _createIterator | ||
*/ | ||
var _createIterator = function _createIterator(root) { | ||
return createNodeIterator.call(root.ownerDocument || root, root, | ||
// eslint-disable-next-line no-bitwise | ||
return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise | ||
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false); | ||
}; | ||
/** | ||
@@ -913,6 +999,7 @@ * _isClobbered | ||
*/ | ||
var _isClobbered = function _isClobbered(elm) { | ||
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'); | ||
}; | ||
/** | ||
@@ -924,6 +1011,7 @@ * _isNode | ||
*/ | ||
var _isNode = function _isNode(object) { | ||
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'; | ||
return _typeof(Node) === 'object' ? object instanceof Node : object && _typeof(object) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'; | ||
}; | ||
/** | ||
@@ -937,2 +1025,4 @@ * _executeHook | ||
*/ | ||
var _executeHook = function _executeHook(entryPoint, currentNode, data) { | ||
@@ -947,3 +1037,2 @@ if (!hooks[entryPoint]) { | ||
}; | ||
/** | ||
@@ -959,24 +1048,31 @@ * _sanitizeElements | ||
*/ | ||
var _sanitizeElements = function _sanitizeElements(currentNode) { | ||
var content = void 0; | ||
var content; | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('beforeSanitizeElements', currentNode, null); | ||
/* Check if element is clobbered or can clobber */ | ||
/* Check if element is clobbered or can clobber */ | ||
if (_isClobbered(currentNode)) { | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Check if tagname contains Unicode */ | ||
/* Check if tagname contains Unicode */ | ||
if (stringMatch(currentNode.nodeName, /[\u0080-\uFFFF]/)) { | ||
if (regExpTest(/[\u0080-\uFFFF]/, currentNode.nodeName)) { | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Now let's check the element's type and name */ | ||
/* Now let's check the element's type and name */ | ||
var tagName = transformCaseFunc(currentNode.nodeName); | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('uponSanitizeElement', currentNode, { | ||
@@ -986,16 +1082,21 @@ tagName: tagName, | ||
}); | ||
/* Detect mXSS attempts abusing namespace confusion */ | ||
/* Detect mXSS attempts abusing namespace confusion */ | ||
if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { | ||
if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Mitigate a problem with templates inside select */ | ||
/* Mitigate a problem with templates inside select */ | ||
if (tagName === 'select' && regExpTest(/<template/i, currentNode.innerHTML)) { | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Remove element if anything forbids its presence */ | ||
/* Remove element if anything forbids its presence */ | ||
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { | ||
@@ -1007,4 +1108,5 @@ /* Check if we have a custom element to handle */ | ||
} | ||
/* Keep content except for bad-listed elements */ | ||
/* Keep content except for bad-listed elements */ | ||
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { | ||
@@ -1024,8 +1126,11 @@ var parentNode = getParentNode(currentNode) || currentNode.parentNode; | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Check whether element has a valid namespace */ | ||
/* Check whether element has a valid namespace */ | ||
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { | ||
_forceRemove(currentNode); | ||
return true; | ||
@@ -1036,18 +1141,24 @@ } | ||
_forceRemove(currentNode); | ||
return true; | ||
} | ||
/* Sanitize element content to be template-safe */ | ||
/* Sanitize element content to be template-safe */ | ||
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) { | ||
/* Get the element's text content */ | ||
content = currentNode.textContent; | ||
content = stringReplace(content, MUSTACHE_EXPR$$1, ' '); | ||
content = stringReplace(content, ERB_EXPR$$1, ' '); | ||
content = stringReplace(content, MUSTACHE_EXPR$1, ' '); | ||
content = stringReplace(content, ERB_EXPR$1, ' '); | ||
if (currentNode.textContent !== content) { | ||
arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() }); | ||
arrayPush(DOMPurify.removed, { | ||
element: currentNode.cloneNode() | ||
}); | ||
currentNode.textContent = content; | ||
} | ||
} | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('afterSanitizeElements', currentNode, null); | ||
@@ -1057,3 +1168,2 @@ | ||
}; | ||
/** | ||
@@ -1068,2 +1178,4 @@ * _isValidAttribute | ||
// eslint-disable-next-line complexity | ||
var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) { | ||
@@ -1074,3 +1186,2 @@ /* Make sure attribute cannot clobber */ | ||
} | ||
/* Allow valid data-* attributes: At least one character after "-" | ||
@@ -1080,9 +1191,9 @@ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) | ||
We don't need to check the value; it's always URI safe. */ | ||
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]) { | ||
if ( | ||
// First condition does a very basic check if a) it's basically a valid custom element tagname AND | ||
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]) { | ||
if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND | ||
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck | ||
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck | ||
_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)) || | ||
// Alternative, second condition checks if it's an `is`-attribute, AND | ||
_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)) || // Alternative, second condition checks if it's an `is`-attribute, AND | ||
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck | ||
@@ -1093,3 +1204,4 @@ 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 { | ||
/* Check value is safe. First, is attr inert? If so, is safe */ | ||
} 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 { | ||
} 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 { | ||
return false; | ||
@@ -1100,3 +1212,2 @@ } | ||
}; | ||
/** | ||
@@ -1108,6 +1219,7 @@ * _basicCustomElementCheck | ||
*/ | ||
var _basicCustomElementTest = function _basicCustomElementTest(tagName) { | ||
return tagName.indexOf('-') > 0; | ||
}; | ||
/** | ||
@@ -1123,12 +1235,14 @@ * _sanitizeAttributes | ||
*/ | ||
var _sanitizeAttributes = function _sanitizeAttributes(currentNode) { | ||
var attr = void 0; | ||
var value = void 0; | ||
var lcName = void 0; | ||
var l = void 0; | ||
var attr; | ||
var value; | ||
var lcName; | ||
var l; | ||
/* Execute a hook if present */ | ||
_executeHook('beforeSanitizeAttributes', currentNode, null); | ||
var attributes = currentNode.attributes; | ||
/* Check if we have attributes; if not we might have a text node */ | ||
@@ -1147,4 +1261,4 @@ | ||
l = attributes.length; | ||
/* Go backwards over all attributes; safely remove bad ones */ | ||
/* Go backwards over all attributes; safely remove bad ones */ | ||
while (l--) { | ||
@@ -1155,7 +1269,6 @@ attr = attributes[l]; | ||
namespaceURI = _attr.namespaceURI; | ||
value = stringTrim(attr.value); | ||
value = name === 'value' ? attr.value : stringTrim(attr.value); | ||
lcName = transformCaseFunc(name); | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
hookEvent.attrName = lcName; | ||
@@ -1165,36 +1278,47 @@ hookEvent.attrValue = value; | ||
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set | ||
_executeHook('uponSanitizeAttribute', currentNode, hookEvent); | ||
value = hookEvent.attrValue; | ||
/* Did the hooks approve of the attribute? */ | ||
if (hookEvent.forceKeepAttr) { | ||
continue; | ||
} | ||
/* Remove attribute */ | ||
/* Remove attribute */ | ||
_removeAttribute(name, currentNode); | ||
/* Did the hooks approve of the attribute? */ | ||
/* Did the hooks approve of the attribute? */ | ||
if (!hookEvent.keepAttr) { | ||
continue; | ||
} | ||
/* Work around a security issue in jQuery 3.0 */ | ||
/* Work around a security issue in jQuery 3.0 */ | ||
if (regExpTest(/\/>/i, value)) { | ||
_removeAttribute(name, currentNode); | ||
continue; | ||
} | ||
/* Sanitize attribute content to be template-safe */ | ||
/* Sanitize attribute content to be template-safe */ | ||
if (SAFE_FOR_TEMPLATES) { | ||
value = stringReplace(value, MUSTACHE_EXPR$$1, ' '); | ||
value = stringReplace(value, ERB_EXPR$$1, ' '); | ||
value = stringReplace(value, MUSTACHE_EXPR$1, ' '); | ||
value = stringReplace(value, ERB_EXPR$1, ' '); | ||
} | ||
/* Is `value` valid for this attribute? */ | ||
/* Is `value` valid for this attribute? */ | ||
var lcTag = transformCaseFunc(currentNode.nodeName); | ||
if (!_isValidAttribute(lcTag, lcName, value)) { | ||
continue; | ||
} | ||
/* Handle invalid data-* attribute set by try-catching it */ | ||
/* Handle invalid data-* attribute set by try-catching it */ | ||
try { | ||
@@ -1211,7 +1335,7 @@ if (namespaceURI) { | ||
} | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('afterSanitizeAttributes', currentNode, null); | ||
}; | ||
/** | ||
@@ -1222,7 +1346,11 @@ * _sanitizeShadowDOM | ||
*/ | ||
var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) { | ||
var shadowNode = void 0; | ||
var shadowNode; | ||
var shadowIterator = _createIterator(fragment); | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('beforeSanitizeShadowDOM', fragment, null); | ||
@@ -1233,21 +1361,24 @@ | ||
_executeHook('uponSanitizeShadowNode', shadowNode, null); | ||
/* Sanitize tags and elements */ | ||
/* Sanitize tags and elements */ | ||
if (_sanitizeElements(shadowNode)) { | ||
continue; | ||
} | ||
/* Deep shadow DOM detected */ | ||
/* Deep shadow DOM detected */ | ||
if (shadowNode.content instanceof DocumentFragment) { | ||
_sanitizeShadowDOM(shadowNode.content); | ||
} | ||
/* Check attributes, sanitize if necessary */ | ||
/* Check attributes, sanitize if necessary */ | ||
_sanitizeAttributes(shadowNode); | ||
} | ||
/* Execute a hook if present */ | ||
/* Execute a hook if present */ | ||
_executeHook('afterSanitizeShadowDOM', fragment, null); | ||
}; | ||
/** | ||
@@ -1261,17 +1392,22 @@ * Sanitize | ||
// eslint-disable-next-line complexity | ||
DOMPurify.sanitize = function (dirty, cfg) { | ||
var body = void 0; | ||
var importedNode = void 0; | ||
var currentNode = void 0; | ||
var oldNode = void 0; | ||
var returnNode = void 0; | ||
var body; | ||
var importedNode; | ||
var currentNode; | ||
var oldNode; | ||
var returnNode; | ||
/* Make sure we have a string to sanitize. | ||
DO NOT return early, as this will return the wrong type if | ||
the user has requested a DOM object rather than a string */ | ||
IS_EMPTY_INPUT = !dirty; | ||
if (IS_EMPTY_INPUT) { | ||
dirty = '<!-->'; | ||
} | ||
/* Stringify, in case dirty is an object */ | ||
/* Stringify, in case dirty is an object */ | ||
if (typeof dirty !== 'string' && !_isNode(dirty)) { | ||
@@ -1283,2 +1419,3 @@ // eslint-disable-next-line no-negated-condition | ||
dirty = dirty.toString(); | ||
if (typeof dirty !== 'string') { | ||
@@ -1289,4 +1426,5 @@ throw typeErrorCreate('dirty is not a string, aborting'); | ||
} | ||
/* Check we can run. Otherwise fall back or ignore */ | ||
/* Check we can run. Otherwise fall back or ignore */ | ||
if (!DOMPurify.isSupported) { | ||
@@ -1305,12 +1443,14 @@ if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') { | ||
} | ||
/* Assign config vars */ | ||
/* Assign config vars */ | ||
if (!SET_CONFIG) { | ||
_parseConfig(cfg); | ||
} | ||
/* Clean up removed elements */ | ||
/* Clean up removed elements */ | ||
DOMPurify.removed = []; | ||
/* Check if dirty is correctly typed for IN_PLACE */ | ||
/* Check if dirty is correctly typed for IN_PLACE */ | ||
if (typeof dirty === 'string') { | ||
@@ -1324,2 +1464,3 @@ IN_PLACE = false; | ||
var tagName = transformCaseFunc(dirty.nodeName); | ||
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { | ||
@@ -1334,2 +1475,3 @@ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place'); | ||
importedNode = body.ownerDocument.importNode(dirty, true); | ||
if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') { | ||
@@ -1346,12 +1488,12 @@ /* Node is already a body, use as is */ | ||
/* Exit directly if we have nothing to do */ | ||
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && | ||
// eslint-disable-next-line unicorn/prefer-includes | ||
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes | ||
dirty.indexOf('<') === -1) { | ||
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; | ||
} | ||
/* Initialize the document to work on */ | ||
/* Initialize the document to work on */ | ||
body = _initDocument(dirty); | ||
/* Check we have a DOM node from the data */ | ||
/* Check we have a DOM node from the data */ | ||
if (!body) { | ||
@@ -1361,12 +1503,15 @@ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : ''; | ||
} | ||
/* Remove first element node (ours) if FORCE_BODY is set */ | ||
/* Remove first element node (ours) if FORCE_BODY is set */ | ||
if (body && FORCE_BODY) { | ||
_forceRemove(body.firstChild); | ||
} | ||
/* Get node iterator */ | ||
/* Get node iterator */ | ||
var nodeIterator = _createIterator(IN_PLACE ? dirty : body); | ||
/* Now start iterating over the created document */ | ||
/* Now start iterating over the created document */ | ||
while (currentNode = nodeIterator.nextNode()) { | ||
@@ -1377,14 +1522,17 @@ /* Fix IE's strange behavior with manipulated textNodes #89 */ | ||
} | ||
/* Sanitize tags and elements */ | ||
/* Sanitize tags and elements */ | ||
if (_sanitizeElements(currentNode)) { | ||
continue; | ||
} | ||
/* Shadow DOM detected, sanitize it */ | ||
/* Shadow DOM detected, sanitize it */ | ||
if (currentNode.content instanceof DocumentFragment) { | ||
_sanitizeShadowDOM(currentNode.content); | ||
} | ||
/* Check attributes, sanitize if necessary */ | ||
/* Check attributes, sanitize if necessary */ | ||
_sanitizeAttributes(currentNode); | ||
@@ -1396,9 +1544,10 @@ | ||
oldNode = null; | ||
/* If we sanitized `dirty` in-place, return it. */ | ||
/* If we sanitized `dirty` in-place, return it. */ | ||
if (IN_PLACE) { | ||
return dirty; | ||
} | ||
/* Return sanitized string or DOM */ | ||
/* Return sanitized string or DOM */ | ||
if (RETURN_DOM) { | ||
@@ -1431,12 +1580,13 @@ if (RETURN_DOM_FRAGMENT) { | ||
var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; | ||
/* Serialize doctype if allowed */ | ||
/* Serialize doctype if allowed */ | ||
if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) { | ||
serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML; | ||
} | ||
/* Sanitize final string template-safe */ | ||
/* Sanitize final string template-safe */ | ||
if (SAFE_FOR_TEMPLATES) { | ||
serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$$1, ' '); | ||
serializedHTML = stringReplace(serializedHTML, ERB_EXPR$$1, ' '); | ||
serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$1, ' '); | ||
serializedHTML = stringReplace(serializedHTML, ERB_EXPR$1, ' '); | ||
} | ||
@@ -1446,3 +1596,2 @@ | ||
}; | ||
/** | ||
@@ -1454,7 +1603,9 @@ * Public method to set the configuration once | ||
*/ | ||
DOMPurify.setConfig = function (cfg) { | ||
_parseConfig(cfg); | ||
SET_CONFIG = true; | ||
}; | ||
/** | ||
@@ -1465,2 +1616,4 @@ * Public method to remove the configuration | ||
*/ | ||
DOMPurify.clearConfig = function () { | ||
@@ -1470,3 +1623,2 @@ CONFIG = null; | ||
}; | ||
/** | ||
@@ -1482,2 +1634,4 @@ * Public method to check if an attribute value is valid. | ||
*/ | ||
DOMPurify.isValidAttribute = function (tag, attr, value) { | ||
@@ -1493,3 +1647,2 @@ /* Initialize shared config vars if necessary. */ | ||
}; | ||
/** | ||
@@ -1502,2 +1655,4 @@ * AddHook | ||
*/ | ||
DOMPurify.addHook = function (entryPoint, hookFunction) { | ||
@@ -1511,3 +1666,2 @@ if (typeof hookFunction !== 'function') { | ||
}; | ||
/** | ||
@@ -1519,9 +1673,11 @@ * RemoveHook | ||
* @param {String} entryPoint entry point for the hook to remove | ||
* @return {Function} removed(popped) hook | ||
*/ | ||
DOMPurify.removeHook = function (entryPoint) { | ||
if (hooks[entryPoint]) { | ||
arrayPop(hooks[entryPoint]); | ||
return arrayPop(hooks[entryPoint]); | ||
} | ||
}; | ||
/** | ||
@@ -1533,2 +1689,4 @@ * RemoveHooks | ||
*/ | ||
DOMPurify.removeHooks = function (entryPoint) { | ||
@@ -1539,3 +1697,2 @@ if (hooks[entryPoint]) { | ||
}; | ||
/** | ||
@@ -1546,2 +1703,4 @@ * RemoveAllHooks | ||
*/ | ||
DOMPurify.removeAllHooks = function () { | ||
@@ -1548,0 +1707,0 @@ hooks = {}; |
@@ -1,3 +0,3 @@ | ||
/*! @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 */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).DOMPurify=t()}(this,(function(){"use strict";var e=Object.hasOwnProperty,t=Object.setPrototypeOf,n=Object.isFrozen,r=Object.getPrototypeOf,o=Object.getOwnPropertyDescriptor,i=Object.freeze,a=Object.seal,l=Object.create,c="undefined"!=typeof Reflect&&Reflect,s=c.apply,u=c.construct;s||(s=function(e,t,n){return e.apply(t,n)}),i||(i=function(e){return e}),a||(a=function(e){return e}),u||(u=function(e,t){return new(Function.prototype.bind.apply(e,[null].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(t))))});var m,f=A(Array.prototype.forEach),d=A(Array.prototype.pop),p=A(Array.prototype.push),h=A(String.prototype.toLowerCase),g=A(String.prototype.match),y=A(String.prototype.replace),v=A(String.prototype.indexOf),b=A(String.prototype.trim),T=A(RegExp.prototype.test),N=(m=TypeError,function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return u(m,t)});function A(e){return function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return s(e,t,r)}}function E(e,r){t&&t(e,null);for(var o=r.length;o--;){var i=r[o];if("string"==typeof i){var a=h(i);a!==i&&(n(r)||(r[o]=a),i=a)}e[i]=!0}return e}function x(t){var n=l(null),r=void 0;for(r in t)s(e,t,[r])&&(n[r]=t[r]);return n}function w(e,t){for(;null!==e;){var n=o(e,t);if(n){if(n.get)return A(n.get);if("function"==typeof n.value)return A(n.value)}e=r(e)}return function(e){return console.warn("fallback value for",e),null}}var k=i(["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"]),S=i(["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"]),_=i(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),D=i(["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"]),O=i(["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"]),C=i(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),M=i(["#text"]),L=i(["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"]),R=i(["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"]),I=i(["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"]),F=i(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),H=a(/\{\{[\s\S]*|[\s\S]*\}\}/gm),U=a(/<%[\s\S]*|[\s\S]*%>/gm),z=a(/^data-[\-\w.\u00B7-\uFFFF]/),B=a(/^aria-[\-\w]+$/),P=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),j=a(/^(?:\w+script|data):/i),G=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),W=a(/^html$/i),q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function Y(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var K=function(){return"undefined"==typeof window?null:window},V=function(e,t){if("object"!==(void 0===e?"undefined":q(e))||"function"!=typeof e.createPolicy)return null;var n=null,r="data-tt-policy-suffix";t.currentScript&&t.currentScript.hasAttribute(r)&&(n=t.currentScript.getAttribute(r));var o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}};return function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:K(),n=function(t){return e(t)};if(n.version="2.3.6",n.removed=[],!t||!t.document||9!==t.document.nodeType)return n.isSupported=!1,n;var r=t.document,o=t.document,a=t.DocumentFragment,l=t.HTMLTemplateElement,c=t.Node,s=t.Element,u=t.NodeFilter,m=t.NamedNodeMap,A=void 0===m?t.NamedNodeMap||t.MozNamedAttrMap:m,$=t.HTMLFormElement,X=t.DOMParser,Z=t.trustedTypes,J=s.prototype,Q=w(J,"cloneNode"),ee=w(J,"nextSibling"),te=w(J,"childNodes"),ne=w(J,"parentNode");if("function"==typeof l){var re=o.createElement("template");re.content&&re.content.ownerDocument&&(o=re.content.ownerDocument)}var oe=V(Z,r),ie=oe?oe.createHTML(""):"",ae=o,le=ae.implementation,ce=ae.createNodeIterator,se=ae.createDocumentFragment,ue=ae.getElementsByTagName,me=r.importNode,fe={};try{fe=x(o).documentMode?o.documentMode:{}}catch(e){}var de={};n.isSupported="function"==typeof ne&&le&&void 0!==le.createHTMLDocument&&9!==fe;var pe=H,he=U,ge=z,ye=B,ve=j,be=G,Te=P,Ne=null,Ae=E({},[].concat(Y(k),Y(S),Y(_),Y(O),Y(M))),Ee=null,xe=E({},[].concat(Y(L),Y(R),Y(I),Y(F))),we=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ke=null,Se=null,_e=!0,De=!0,Oe=!1,Ce=!1,Me=!1,Le=!1,Re=!1,Ie=!1,Fe=!1,He=!1,Ue=!0,ze=!0,Be=!1,Pe={},je=null,Ge=E({},["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"]),We=null,qe=E({},["audio","video","img","source","image","track"]),Ye=null,Ke=E({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ve="http://www.w3.org/1998/Math/MathML",$e="http://www.w3.org/2000/svg",Xe="http://www.w3.org/1999/xhtml",Ze=Xe,Je=!1,Qe=void 0,et=["application/xhtml+xml","text/html"],tt="text/html",nt=void 0,rt=null,ot=o.createElement("form"),it=function(e){return e instanceof RegExp||e instanceof Function},at=function(e){rt&&rt===e||(e&&"object"===(void 0===e?"undefined":q(e))||(e={}),e=x(e),Ne="ALLOWED_TAGS"in e?E({},e.ALLOWED_TAGS):Ae,Ee="ALLOWED_ATTR"in e?E({},e.ALLOWED_ATTR):xe,Ye="ADD_URI_SAFE_ATTR"in e?E(x(Ke),e.ADD_URI_SAFE_ATTR):Ke,We="ADD_DATA_URI_TAGS"in e?E(x(qe),e.ADD_DATA_URI_TAGS):qe,je="FORBID_CONTENTS"in e?E({},e.FORBID_CONTENTS):Ge,ke="FORBID_TAGS"in e?E({},e.FORBID_TAGS):{},Se="FORBID_ATTR"in e?E({},e.FORBID_ATTR):{},Pe="USE_PROFILES"in e&&e.USE_PROFILES,_e=!1!==e.ALLOW_ARIA_ATTR,De=!1!==e.ALLOW_DATA_ATTR,Oe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ce=e.SAFE_FOR_TEMPLATES||!1,Me=e.WHOLE_DOCUMENT||!1,Ie=e.RETURN_DOM||!1,Fe=e.RETURN_DOM_FRAGMENT||!1,He=e.RETURN_TRUSTED_TYPE||!1,Re=e.FORCE_BODY||!1,Ue=!1!==e.SANITIZE_DOM,ze=!1!==e.KEEP_CONTENT,Be=e.IN_PLACE||!1,Te=e.ALLOWED_URI_REGEXP||Te,Ze=e.NAMESPACE||Xe,e.CUSTOM_ELEMENT_HANDLING&&it(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(we.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&it(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(we.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(we.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Qe=Qe=-1===et.indexOf(e.PARSER_MEDIA_TYPE)?tt:e.PARSER_MEDIA_TYPE,nt="application/xhtml+xml"===Qe?function(e){return e}:h,Ce&&(De=!1),Fe&&(Ie=!0),Pe&&(Ne=E({},[].concat(Y(M))),Ee=[],!0===Pe.html&&(E(Ne,k),E(Ee,L)),!0===Pe.svg&&(E(Ne,S),E(Ee,R),E(Ee,F)),!0===Pe.svgFilters&&(E(Ne,_),E(Ee,R),E(Ee,F)),!0===Pe.mathMl&&(E(Ne,O),E(Ee,I),E(Ee,F))),e.ADD_TAGS&&(Ne===Ae&&(Ne=x(Ne)),E(Ne,e.ADD_TAGS)),e.ADD_ATTR&&(Ee===xe&&(Ee=x(Ee)),E(Ee,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&E(Ye,e.ADD_URI_SAFE_ATTR),e.FORBID_CONTENTS&&(je===Ge&&(je=x(je)),E(je,e.FORBID_CONTENTS)),ze&&(Ne["#text"]=!0),Me&&E(Ne,["html","head","body"]),Ne.table&&(E(Ne,["tbody"]),delete ke.tbody),i&&i(e),rt=e)},lt=E({},["mi","mo","mn","ms","mtext"]),ct=E({},["foreignobject","desc","title","annotation-xml"]),st=E({},S);E(st,_),E(st,D);var ut=E({},O);E(ut,C);var mt=function(e){var t=ne(e);t&&t.tagName||(t={namespaceURI:Xe,tagName:"template"});var n=h(e.tagName),r=h(t.tagName);if(e.namespaceURI===$e)return t.namespaceURI===Xe?"svg"===n:t.namespaceURI===Ve?"svg"===n&&("annotation-xml"===r||lt[r]):Boolean(st[n]);if(e.namespaceURI===Ve)return t.namespaceURI===Xe?"math"===n:t.namespaceURI===$e?"math"===n&&ct[r]:Boolean(ut[n]);if(e.namespaceURI===Xe){if(t.namespaceURI===$e&&!ct[r])return!1;if(t.namespaceURI===Ve&&!lt[r])return!1;var o=E({},["title","style","font","a","script"]);return!ut[n]&&(o[n]||!st[n])}return!1},ft=function(e){p(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=ie}catch(t){e.remove()}}},dt=function(e,t){try{p(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){p(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!Ee[e])if(Ie||Fe)try{ft(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},pt=function(e){var t=void 0,n=void 0;if(Re)e="<remove></remove>"+e;else{var r=g(e,/^[\r\n\t ]+/);n=r&&r[0]}"application/xhtml+xml"===Qe&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");var i=oe?oe.createHTML(e):e;if(Ze===Xe)try{t=(new X).parseFromString(i,Qe)}catch(e){}if(!t||!t.documentElement){t=le.createDocument(Ze,"template",null);try{t.documentElement.innerHTML=Je?"":i}catch(e){}}var a=t.body||t.documentElement;return e&&n&&a.insertBefore(o.createTextNode(n),a.childNodes[0]||null),Ze===Xe?ue.call(t,Me?"html":"body")[0]:Me?t.documentElement:a},ht=function(e){return ce.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,null,!1)},gt=function(e){return e instanceof $&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof A)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore)},yt=function(e){return"object"===(void 0===c?"undefined":q(c))?e instanceof c:e&&"object"===(void 0===e?"undefined":q(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},vt=function(e,t,r){de[e]&&f(de[e],(function(e){e.call(n,t,r,rt)}))},bt=function(e){var t=void 0;if(vt("beforeSanitizeElements",e,null),gt(e))return ft(e),!0;if(g(e.nodeName,/[\u0080-\uFFFF]/))return ft(e),!0;var r=nt(e.nodeName);if(vt("uponSanitizeElement",e,{tagName:r,allowedTags:Ne}),!yt(e.firstElementChild)&&(!yt(e.content)||!yt(e.content.firstElementChild))&&T(/<[/\w]/g,e.innerHTML)&&T(/<[/\w]/g,e.textContent))return ft(e),!0;if("select"===r&&T(/<template/i,e.innerHTML))return ft(e),!0;if(!Ne[r]||ke[r]){if(!ke[r]&&Nt(r)){if(we.tagNameCheck instanceof RegExp&&T(we.tagNameCheck,r))return!1;if(we.tagNameCheck instanceof Function&&we.tagNameCheck(r))return!1}if(ze&&!je[r]){var o=ne(e)||e.parentNode,i=te(e)||e.childNodes;if(i&&o)for(var a=i.length-1;a>=0;--a)o.insertBefore(Q(i[a],!0),ee(e))}return ft(e),!0}return e instanceof s&&!mt(e)?(ft(e),!0):"noscript"!==r&&"noembed"!==r||!T(/<\/no(script|embed)/i,e.innerHTML)?(Ce&&3===e.nodeType&&(t=e.textContent,t=y(t,pe," "),t=y(t,he," "),e.textContent!==t&&(p(n.removed,{element:e.cloneNode()}),e.textContent=t)),vt("afterSanitizeElements",e,null),!1):(ft(e),!0)},Tt=function(e,t,n){if(Ue&&("id"===t||"name"===t)&&(n in o||n in ot))return!1;if(De&&!Se[t]&&T(ge,t));else if(_e&&T(ye,t));else if(!Ee[t]||Se[t]){if(!(Nt(e)&&(we.tagNameCheck instanceof RegExp&&T(we.tagNameCheck,e)||we.tagNameCheck instanceof Function&&we.tagNameCheck(e))&&(we.attributeNameCheck instanceof RegExp&&T(we.attributeNameCheck,t)||we.attributeNameCheck instanceof Function&&we.attributeNameCheck(t))||"is"===t&&we.allowCustomizedBuiltInElements&&(we.tagNameCheck instanceof RegExp&&T(we.tagNameCheck,n)||we.tagNameCheck instanceof Function&&we.tagNameCheck(n))))return!1}else if(Ye[t]);else if(T(Te,y(n,be,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==v(n,"data:")||!We[e]){if(Oe&&!T(ve,y(n,be,"")));else if(n)return!1}else;return!0},Nt=function(e){return e.indexOf("-")>0},At=function(e){var t=void 0,r=void 0,o=void 0,i=void 0;vt("beforeSanitizeAttributes",e,null);var a=e.attributes;if(a){var l={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ee};for(i=a.length;i--;){var c=t=a[i],s=c.name,u=c.namespaceURI;if(r=b(t.value),o=nt(s),l.attrName=o,l.attrValue=r,l.keepAttr=!0,l.forceKeepAttr=void 0,vt("uponSanitizeAttribute",e,l),r=l.attrValue,!l.forceKeepAttr&&(dt(s,e),l.keepAttr))if(T(/\/>/i,r))dt(s,e);else{Ce&&(r=y(r,pe," "),r=y(r,he," "));var m=nt(e.nodeName);if(Tt(m,o,r))try{u?e.setAttributeNS(u,s,r):e.setAttribute(s,r),d(n.removed)}catch(e){}}}vt("afterSanitizeAttributes",e,null)}},Et=function e(t){var n=void 0,r=ht(t);for(vt("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)vt("uponSanitizeShadowNode",n,null),bt(n)||(n.content instanceof a&&e(n.content),At(n));vt("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e,o){var i=void 0,l=void 0,s=void 0,u=void 0,m=void 0;if((Je=!e)&&(e="\x3c!--\x3e"),"string"!=typeof e&&!yt(e)){if("function"!=typeof e.toString)throw N("toString is not a function");if("string"!=typeof(e=e.toString()))throw N("dirty is not a string, aborting")}if(!n.isSupported){if("object"===q(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof e)return t.toStaticHTML(e);if(yt(e))return t.toStaticHTML(e.outerHTML)}return e}if(Le||at(o),n.removed=[],"string"==typeof e&&(Be=!1),Be){if(e.nodeName){var f=nt(e.nodeName);if(!Ne[f]||ke[f])throw N("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof c)1===(l=(i=pt("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===l.nodeName||"HTML"===l.nodeName?i=l:i.appendChild(l);else{if(!Ie&&!Ce&&!Me&&-1===e.indexOf("<"))return oe&&He?oe.createHTML(e):e;if(!(i=pt(e)))return Ie?null:He?ie:""}i&&Re&&ft(i.firstChild);for(var d=ht(Be?e:i);s=d.nextNode();)3===s.nodeType&&s===u||bt(s)||(s.content instanceof a&&Et(s.content),At(s),u=s);if(u=null,Be)return e;if(Ie){if(Fe)for(m=se.call(i.ownerDocument);i.firstChild;)m.appendChild(i.firstChild);else m=i;return Ee.shadowroot&&(m=me.call(r,m,!0)),m}var p=Me?i.outerHTML:i.innerHTML;return Me&&Ne["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&T(W,i.ownerDocument.doctype.name)&&(p="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+p),Ce&&(p=y(p,pe," "),p=y(p,he," ")),oe&&He?oe.createHTML(p):p},n.setConfig=function(e){at(e),Le=!0},n.clearConfig=function(){rt=null,Le=!1},n.isValidAttribute=function(e,t,n){rt||at({});var r=nt(e),o=nt(t);return Tt(r,o,n)},n.addHook=function(e,t){"function"==typeof t&&(de[e]=de[e]||[],p(de[e],t))},n.removeHook=function(e){de[e]&&d(de[e])},n.removeHooks=function(e){de[e]&&(de[e]=[])},n.removeAllHooks=function(){de={}},n}()})); | ||
/*! @license DOMPurify 2.3.7 | (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.7/LICENSE */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DOMPurify=t()}(this,(function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,n){return(t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,n)}function n(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function r(e,o,a){return(r=n()?Reflect.construct:function(e,n,r){var o=[null];o.push.apply(o,n);var a=new(Function.bind.apply(e,o));return r&&t(a,r.prototype),a}).apply(null,arguments)}function o(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var i=Object.hasOwnProperty,l=Object.setPrototypeOf,c=Object.isFrozen,u=Object.getPrototypeOf,s=Object.getOwnPropertyDescriptor,m=Object.freeze,f=Object.seal,p=Object.create,d="undefined"!=typeof Reflect&&Reflect,h=d.apply,g=d.construct;h||(h=function(e,t,n){return e.apply(t,n)}),m||(m=function(e){return e}),f||(f=function(e){return e}),g||(g=function(e,t){return r(e,o(t))});var y,b=_(Array.prototype.forEach),v=_(Array.prototype.pop),T=_(Array.prototype.push),N=_(String.prototype.toLowerCase),E=_(String.prototype.match),A=_(String.prototype.replace),w=_(String.prototype.indexOf),x=_(String.prototype.trim),k=_(RegExp.prototype.test),S=(y=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g(y,t)});function _(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return h(e,t,r)}}function O(e,t){l&&l(e,null);for(var n=t.length;n--;){var r=t[n];if("string"==typeof r){var o=N(r);o!==r&&(c(t)||(t[n]=o),r=o)}e[r]=!0}return e}function D(e){var t,n=p(null);for(t in e)h(i,e,[t])&&(n[t]=e[t]);return n}function C(e,t){for(;null!==e;){var n=s(e,t);if(n){if(n.get)return _(n.get);if("function"==typeof n.value)return _(n.value)}e=u(e)}return function(e){return console.warn("fallback value for",e),null}}var M=m(["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"]),R=m(["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"]),L=m(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),I=m(["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"]),F=m(["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"]),H=m(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),U=m(["#text"]),z=m(["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"]),B=m(["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"]),j=m(["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"]),P=m(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),G=f(/\{\{[\w\W]*|[\w\W]*\}\}/gm),W=f(/<%[\w\W]*|[\w\W]*%>/gm),q=f(/^data-[\-\w.\u00B7-\uFFFF]/),Y=f(/^aria-[\-\w]+$/),K=f(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),V=f(/^(?:\w+script|data):/i),$=f(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),X=f(/^html$/i),Z=function(){return"undefined"==typeof window?null:window},J=function(t,n){if("object"!==e(t)||"function"!=typeof t.createPolicy)return null;var r=null,o="data-tt-policy-suffix";n.currentScript&&n.currentScript.hasAttribute(o)&&(r=n.currentScript.getAttribute(o));var a="dompurify"+(r?"#"+r:"");try{return t.createPolicy(a,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+a+" could not be created."),null}};return function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Z(),r=function(e){return t(e)};if(r.version="2.3.7",r.removed=[],!n||!n.document||9!==n.document.nodeType)return r.isSupported=!1,r;var a=n.document,i=n.document,l=n.DocumentFragment,c=n.HTMLTemplateElement,u=n.Node,s=n.Element,f=n.NodeFilter,p=n.NamedNodeMap,d=void 0===p?n.NamedNodeMap||n.MozNamedAttrMap:p,h=n.HTMLFormElement,g=n.DOMParser,y=n.trustedTypes,_=s.prototype,Q=C(_,"cloneNode"),ee=C(_,"nextSibling"),te=C(_,"childNodes"),ne=C(_,"parentNode");if("function"==typeof c){var re=i.createElement("template");re.content&&re.content.ownerDocument&&(i=re.content.ownerDocument)}var oe=J(y,a),ae=oe?oe.createHTML(""):"",ie=i,le=ie.implementation,ce=ie.createNodeIterator,ue=ie.createDocumentFragment,se=ie.getElementsByTagName,me=a.importNode,fe={};try{fe=D(i).documentMode?i.documentMode:{}}catch(e){}var pe={};r.isSupported="function"==typeof ne&&le&&void 0!==le.createHTMLDocument&&9!==fe;var de,he,ge=G,ye=W,be=q,ve=Y,Te=V,Ne=$,Ee=K,Ae=null,we=O({},[].concat(o(M),o(R),o(L),o(F),o(U))),xe=null,ke=O({},[].concat(o(z),o(B),o(j),o(P))),Se=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),_e=null,Oe=null,De=!0,Ce=!0,Me=!1,Re=!1,Le=!1,Ie=!1,Fe=!1,He=!1,Ue=!1,ze=!1,Be=!0,je=!0,Pe=!1,Ge={},We=null,qe=O({},["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"]),Ye=null,Ke=O({},["audio","video","img","source","image","track"]),Ve=null,$e=O({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Xe="http://www.w3.org/1998/Math/MathML",Ze="http://www.w3.org/2000/svg",Je="http://www.w3.org/1999/xhtml",Qe=Je,et=!1,tt=["application/xhtml+xml","text/html"],nt="text/html",rt=null,ot=i.createElement("form"),at=function(e){return e instanceof RegExp||e instanceof Function},it=function(t){rt&&rt===t||(t&&"object"===e(t)||(t={}),t=D(t),Ae="ALLOWED_TAGS"in t?O({},t.ALLOWED_TAGS):we,xe="ALLOWED_ATTR"in t?O({},t.ALLOWED_ATTR):ke,Ve="ADD_URI_SAFE_ATTR"in t?O(D($e),t.ADD_URI_SAFE_ATTR):$e,Ye="ADD_DATA_URI_TAGS"in t?O(D(Ke),t.ADD_DATA_URI_TAGS):Ke,We="FORBID_CONTENTS"in t?O({},t.FORBID_CONTENTS):qe,_e="FORBID_TAGS"in t?O({},t.FORBID_TAGS):{},Oe="FORBID_ATTR"in t?O({},t.FORBID_ATTR):{},Ge="USE_PROFILES"in t&&t.USE_PROFILES,De=!1!==t.ALLOW_ARIA_ATTR,Ce=!1!==t.ALLOW_DATA_ATTR,Me=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Re=t.SAFE_FOR_TEMPLATES||!1,Le=t.WHOLE_DOCUMENT||!1,He=t.RETURN_DOM||!1,Ue=t.RETURN_DOM_FRAGMENT||!1,ze=t.RETURN_TRUSTED_TYPE||!1,Fe=t.FORCE_BODY||!1,Be=!1!==t.SANITIZE_DOM,je=!1!==t.KEEP_CONTENT,Pe=t.IN_PLACE||!1,Ee=t.ALLOWED_URI_REGEXP||Ee,Qe=t.NAMESPACE||Je,t.CUSTOM_ELEMENT_HANDLING&&at(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Se.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&at(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Se.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Se.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),de=de=-1===tt.indexOf(t.PARSER_MEDIA_TYPE)?nt:t.PARSER_MEDIA_TYPE,he="application/xhtml+xml"===de?function(e){return e}:N,Re&&(Ce=!1),Ue&&(He=!0),Ge&&(Ae=O({},o(U)),xe=[],!0===Ge.html&&(O(Ae,M),O(xe,z)),!0===Ge.svg&&(O(Ae,R),O(xe,B),O(xe,P)),!0===Ge.svgFilters&&(O(Ae,L),O(xe,B),O(xe,P)),!0===Ge.mathMl&&(O(Ae,F),O(xe,j),O(xe,P))),t.ADD_TAGS&&(Ae===we&&(Ae=D(Ae)),O(Ae,t.ADD_TAGS)),t.ADD_ATTR&&(xe===ke&&(xe=D(xe)),O(xe,t.ADD_ATTR)),t.ADD_URI_SAFE_ATTR&&O(Ve,t.ADD_URI_SAFE_ATTR),t.FORBID_CONTENTS&&(We===qe&&(We=D(We)),O(We,t.FORBID_CONTENTS)),je&&(Ae["#text"]=!0),Le&&O(Ae,["html","head","body"]),Ae.table&&(O(Ae,["tbody"]),delete _e.tbody),m&&m(t),rt=t)},lt=O({},["mi","mo","mn","ms","mtext"]),ct=O({},["foreignobject","desc","title","annotation-xml"]),ut=O({},["title","style","font","a","script"]),st=O({},R);O(st,L),O(st,I);var mt=O({},F);O(mt,H);var ft=function(e){var t=ne(e);t&&t.tagName||(t={namespaceURI:Je,tagName:"template"});var n=N(e.tagName),r=N(t.tagName);return e.namespaceURI===Ze?t.namespaceURI===Je?"svg"===n:t.namespaceURI===Xe?"svg"===n&&("annotation-xml"===r||lt[r]):Boolean(st[n]):e.namespaceURI===Xe?t.namespaceURI===Je?"math"===n:t.namespaceURI===Ze?"math"===n&&ct[r]:Boolean(mt[n]):e.namespaceURI===Je&&(!(t.namespaceURI===Ze&&!ct[r])&&(!(t.namespaceURI===Xe&&!lt[r])&&(!mt[n]&&(ut[n]||!st[n]))))},pt=function(e){T(r.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=ae}catch(t){e.remove()}}},dt=function(e,t){try{T(r.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){T(r.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!xe[e])if(He||Ue)try{pt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},ht=function(e){var t,n;if(Fe)e="<remove></remove>"+e;else{var r=E(e,/^[\r\n\t ]+/);n=r&&r[0]}"application/xhtml+xml"===de&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");var o=oe?oe.createHTML(e):e;if(Qe===Je)try{t=(new g).parseFromString(o,de)}catch(e){}if(!t||!t.documentElement){t=le.createDocument(Qe,"template",null);try{t.documentElement.innerHTML=et?"":o}catch(e){}}var a=t.body||t.documentElement;return e&&n&&a.insertBefore(i.createTextNode(n),a.childNodes[0]||null),Qe===Je?se.call(t,Le?"html":"body")[0]:Le?t.documentElement:a},gt=function(e){return ce.call(e.ownerDocument||e,e,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT,null,!1)},yt=function(e){return e instanceof h&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof d)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore)},bt=function(t){return"object"===e(u)?t instanceof u:t&&"object"===e(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},vt=function(e,t,n){pe[e]&&b(pe[e],(function(e){e.call(r,t,n,rt)}))},Tt=function(e){var t;if(vt("beforeSanitizeElements",e,null),yt(e))return pt(e),!0;if(k(/[\u0080-\uFFFF]/,e.nodeName))return pt(e),!0;var n=he(e.nodeName);if(vt("uponSanitizeElement",e,{tagName:n,allowedTags:Ae}),e.hasChildNodes()&&!bt(e.firstElementChild)&&(!bt(e.content)||!bt(e.content.firstElementChild))&&k(/<[/\w]/g,e.innerHTML)&&k(/<[/\w]/g,e.textContent))return pt(e),!0;if("select"===n&&k(/<template/i,e.innerHTML))return pt(e),!0;if(!Ae[n]||_e[n]){if(!_e[n]&&Et(n)){if(Se.tagNameCheck instanceof RegExp&&k(Se.tagNameCheck,n))return!1;if(Se.tagNameCheck instanceof Function&&Se.tagNameCheck(n))return!1}if(je&&!We[n]){var o=ne(e)||e.parentNode,a=te(e)||e.childNodes;if(a&&o)for(var i=a.length-1;i>=0;--i)o.insertBefore(Q(a[i],!0),ee(e))}return pt(e),!0}return e instanceof s&&!ft(e)?(pt(e),!0):"noscript"!==n&&"noembed"!==n||!k(/<\/no(script|embed)/i,e.innerHTML)?(Re&&3===e.nodeType&&(t=e.textContent,t=A(t,ge," "),t=A(t,ye," "),e.textContent!==t&&(T(r.removed,{element:e.cloneNode()}),e.textContent=t)),vt("afterSanitizeElements",e,null),!1):(pt(e),!0)},Nt=function(e,t,n){if(Be&&("id"===t||"name"===t)&&(n in i||n in ot))return!1;if(Ce&&!Oe[t]&&k(be,t));else if(De&&k(ve,t));else if(!xe[t]||Oe[t]){if(!(Et(e)&&(Se.tagNameCheck instanceof RegExp&&k(Se.tagNameCheck,e)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(e))&&(Se.attributeNameCheck instanceof RegExp&&k(Se.attributeNameCheck,t)||Se.attributeNameCheck instanceof Function&&Se.attributeNameCheck(t))||"is"===t&&Se.allowCustomizedBuiltInElements&&(Se.tagNameCheck instanceof RegExp&&k(Se.tagNameCheck,n)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(n))))return!1}else if(Ve[t]);else if(k(Ee,A(n,Ne,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==w(n,"data:")||!Ye[e]){if(Me&&!k(Te,A(n,Ne,"")));else if(n)return!1}else;return!0},Et=function(e){return e.indexOf("-")>0},At=function(e){var t,n,o,a;vt("beforeSanitizeAttributes",e,null);var i=e.attributes;if(i){var l={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xe};for(a=i.length;a--;){var c=t=i[a],u=c.name,s=c.namespaceURI;if(n="value"===u?t.value:x(t.value),o=he(u),l.attrName=o,l.attrValue=n,l.keepAttr=!0,l.forceKeepAttr=void 0,vt("uponSanitizeAttribute",e,l),n=l.attrValue,!l.forceKeepAttr&&(dt(u,e),l.keepAttr))if(k(/\/>/i,n))dt(u,e);else{Re&&(n=A(n,ge," "),n=A(n,ye," "));var m=he(e.nodeName);if(Nt(m,o,n))try{s?e.setAttributeNS(s,u,n):e.setAttribute(u,n),v(r.removed)}catch(e){}}}vt("afterSanitizeAttributes",e,null)}},wt=function e(t){var n,r=gt(t);for(vt("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)vt("uponSanitizeShadowNode",n,null),Tt(n)||(n.content instanceof l&&e(n.content),At(n));vt("afterSanitizeShadowDOM",t,null)};return r.sanitize=function(t,o){var i,c,s,m,f;if((et=!t)&&(t="\x3c!--\x3e"),"string"!=typeof t&&!bt(t)){if("function"!=typeof t.toString)throw S("toString is not a function");if("string"!=typeof(t=t.toString()))throw S("dirty is not a string, aborting")}if(!r.isSupported){if("object"===e(n.toStaticHTML)||"function"==typeof n.toStaticHTML){if("string"==typeof t)return n.toStaticHTML(t);if(bt(t))return n.toStaticHTML(t.outerHTML)}return t}if(Ie||it(o),r.removed=[],"string"==typeof t&&(Pe=!1),Pe){if(t.nodeName){var p=he(t.nodeName);if(!Ae[p]||_e[p])throw S("root node is forbidden and cannot be sanitized in-place")}}else if(t instanceof u)1===(c=(i=ht("\x3c!----\x3e")).ownerDocument.importNode(t,!0)).nodeType&&"BODY"===c.nodeName||"HTML"===c.nodeName?i=c:i.appendChild(c);else{if(!He&&!Re&&!Le&&-1===t.indexOf("<"))return oe&&ze?oe.createHTML(t):t;if(!(i=ht(t)))return He?null:ze?ae:""}i&&Fe&&pt(i.firstChild);for(var d=gt(Pe?t:i);s=d.nextNode();)3===s.nodeType&&s===m||Tt(s)||(s.content instanceof l&&wt(s.content),At(s),m=s);if(m=null,Pe)return t;if(He){if(Ue)for(f=ue.call(i.ownerDocument);i.firstChild;)f.appendChild(i.firstChild);else f=i;return xe.shadowroot&&(f=me.call(a,f,!0)),f}var h=Le?i.outerHTML:i.innerHTML;return Le&&Ae["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&k(X,i.ownerDocument.doctype.name)&&(h="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+h),Re&&(h=A(h,ge," "),h=A(h,ye," ")),oe&&ze?oe.createHTML(h):h},r.setConfig=function(e){it(e),Ie=!0},r.clearConfig=function(){rt=null,Ie=!1},r.isValidAttribute=function(e,t,n){rt||it({});var r=he(e),o=he(t);return Nt(r,o,n)},r.addHook=function(e,t){"function"==typeof t&&(pe[e]=pe[e]||[],T(pe[e],t))},r.removeHook=function(e){if(pe[e])return v(pe[e])},r.removeHooks=function(e){pe[e]&&(pe[e]=[])},r.removeAllHooks=function(){pe={}},r}()})); | ||
//# sourceMappingURL=purify.min.js.map |
@@ -64,34 +64,29 @@ { | ||
"devDependencies": { | ||
"@babel/plugin-external-helpers": "7.12.13", | ||
"babel-core": "^6.26.3", | ||
"babel-preset-env": "^1.7.0", | ||
"@babel/core": "^7.17.8", | ||
"@babel/preset-env": "^7.16.11", | ||
"@rollup/plugin-babel": "^5.3.1", | ||
"@rollup/plugin-commonjs": "^21.0.3", | ||
"@rollup/plugin-node-resolve": "^13.1.3", | ||
"@rollup/plugin-replace": "^4.0.0", | ||
"cross-env": "^7.0.3", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"he": "^1.2.0", | ||
"jquery": "^3.6.0", | ||
"jsdom": "16.x.x", | ||
"karma": "^6.3.14", | ||
"jsdom": "^19.0.0", | ||
"karma": "^6.3.17", | ||
"karma-browserstack-launcher": "^1.5.1", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-firefox-launcher": "^2.1.2", | ||
"karma-fixture": "^0.2.6", | ||
"karma-html2js-preprocessor": "^1.0.0", | ||
"karma-json-fixtures-preprocessor": "0.0.6", | ||
"karma-qunit": "^4.1.2", | ||
"karma-rollup-preprocessor": "^5.0.2", | ||
"karma-rollup-preprocessor": "^7.0.8", | ||
"lodash.sample": "^4.2.1", | ||
"minimist": "^1.2.5", | ||
"minimist": "^1.2.6", | ||
"npm-run-all": "^4.1.5", | ||
"pre-commit": "^1.2.2", | ||
"prettier": "^2.5.1", | ||
"qunit": "^2.4.1", | ||
"qunit-tap": "^1.5.0", | ||
"qunit": "^2.4.1", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^0.68.2", | ||
"rollup-plugin-babel": "^3.0.3", | ||
"rollup-plugin-commonjs": "^8.4.1", | ||
"rollup": "^2.70.1", | ||
"rollup-plugin-includepaths": "^0.2.3", | ||
"rollup-plugin-node-resolve": "^3.4.0", | ||
"rollup-plugin-replace": "^2.2.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
@@ -105,3 +100,3 @@ "xo": "^0.48.0" | ||
"description": "DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. It's written in JavaScript and works in all modern browsers (Safari, Opera (15+), Internet Explorer (10+), Firefox and Chrome - as well as almost anything else using Blink or WebKit). DOMPurify is written by security people who have vast background in web attacks and XSS. Fear not.", | ||
"version": "2.3.6", | ||
"version": "2.3.7", | ||
"directories": { | ||
@@ -108,0 +103,0 @@ "test": "test" |
@@ -9,7 +9,7 @@ # DOMPurify | ||
It's also very simple to use and get started with. DOMPurify was [started in February 2014](https://github.com/cure53/DOMPurify/commit/a630922616927373485e0e787ab19e73e3691b2b) and, meanwhile, has reached version 2.3.6. | ||
It's also very simple to use and get started with. DOMPurify was [started in February 2014](https://github.com/cure53/DOMPurify/commit/a630922616927373485e0e787ab19e73e3691b2b) and, meanwhile, has reached version 2.3.7. | ||
DOMPurify is written in JavaScript and works in all modern browsers (Safari (10+), Opera (15+), Internet Explorer (10+), Edge, Firefox and Chrome - as well as almost anything else using Blink or WebKit). It doesn't break on MSIE6 or other legacy browsers. It either uses [a fall-back](#what-about-older-browsers-like-msie8) or simply does nothing. | ||
Our automated tests cover [19 different browsers](https://github.com/cure53/DOMPurify/blob/main/test/karma.custom-launchers.config.js#L5) right now, more to come. We also cover Node.js v14.15.1, v15.4.0, v16.13.0, v17.0.0, running DOMPurify on [jsdom](https://github.com/tmpvar/jsdom). Older Node.js versions are known to work as well. | ||
Our automated tests cover [19 different browsers](https://github.com/cure53/DOMPurify/blob/main/test/karma.custom-launchers.config.js#L5) right now, more to come. We also cover Node.js v14.15.1, v15.4.0, v16.13.0, v17.0.0, running DOMPurify on [jsdom](https://github.com/jsdom/jsdom). Older Node.js versions are known to work as well. | ||
@@ -59,3 +59,3 @@ DOMPurify is written by security people who have vast background in web attacks and XSS. Fear not. For more details please also read about our [Security Goals & Threat Model](https://github.com/cure53/DOMPurify/wiki/Security-Goals-&-Threat-Model). Please, read it. Like, really. | ||
If you're using an [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) module loader like [Require.js](http://requirejs.org/), you can load this script asynchronously as well: | ||
If you're using an [AMD](https://github.com/amdjs/amdjs-api/blob/master/AMD.md) module loader like [Require.js](http://requirejs.org/), you can load this script asynchronously as well: | ||
@@ -106,3 +106,3 @@ ```js | ||
Also, you probably qualify for a bug bounty! The fine folks over at [Fastmail](https://www.fastmail.com/) use DOMPurify for their services and added our library to their bug bounty scope. So, if you find a way to bypass or weaken DOMPurify, please also have a look at their website and the [bug bounty info](https://www.fastmail.com/about/bugbounty.html). | ||
Also, you probably qualify for a bug bounty! The fine folks over at [Fastmail](https://www.fastmail.com/) use DOMPurify for their services and added our library to their bug bounty scope. So, if you find a way to bypass or weaken DOMPurify, please also have a look at their website and the [bug bounty info](https://www.fastmail.com/about/bugbounty/). | ||
@@ -136,3 +136,3 @@ ## Some purification samples please? | ||
In version 1.0.9, support for [Trusted Types API](https://github.com/WICG/trusted-types) was added to DOMPurify. | ||
In version 1.0.9, support for [Trusted Types API](https://github.com/w3c/webappsec-trusted-types) was added to DOMPurify. | ||
In version 2.0.0, a config flag was added to control DOMPurify's behavior regarding this. | ||
@@ -351,3 +351,3 @@ | ||
We support `npm` officially. GitHub Actions workflow is configured to install dependencies using `npm`. When using deprected version of `npm` we can not fully ensure the versions of installed dependencies which might lead to unanticipated problems. | ||
We support `npm` officially. GitHub Actions workflow is configured to install dependencies using `npm`. When using deprecated version of `npm` we can not fully ensure the versions of installed dependencies which might lead to unanticipated problems. | ||
@@ -386,3 +386,3 @@ #### Scripts | ||
[jarrodldavis 💸](https://github.com/jarrodldavis), [GrantGryczan 💸](https://github.com/GrantGryczan), [lowdefy 💸](https://twitter.com/lowdefy), [granlem 💸](https://twitter.com/MaximeVeit), [oreoshake 💸](https://github.com/oreoshake), [dcramer 💸](https://github.com/dcramer),[tdeekens ❤️](https://github.com/tdeekens), [peernohell ❤️](https://github.com/peernohell), [is2ei](https://github.com/is2ei), [franktopel](https://github.com/franktopel), [NateScarlet](https://github.com/NateScarlet), [neilj](https://github.com/neilj), [fhemberger](https://github.com/fhemberger), [Joris-van-der-Wel](https://github.com/Joris-van-der-Wel), [ydaniv](https://github.com/ydaniv), [terjanq](https://twitter.com/terjanq), [filedescriptor](https://github.com/filedescriptor), [ConradIrwin](https://github.com/ConradIrwin), [gibson042](https://github.com/gibson042), [choumx](https://github.com/choumx), [0xSobky](https://github.com/0xSobky), [styfle](https://github.com/styfle), [koto](https://github.com/koto), [tlau88](https://github.com/tlau88), [strugee](https://github.com/strugee), [oparoz](https://github.com/oparoz), [mathiasbynens](https://github.com/mathiasbynens), [edg2s](https://github.com/edg2s), [dnkolegov](https://github.com/dnkolegov), [dhardtke](https://github.com/dhardtke), [wirehead](https://github.com/wirehead), [thorn0](https://github.com/thorn0), [styu](https://github.com/styu), [mozfreddyb](https://github.com/mozfreddyb), [mikesamuel](https://github.com/mikesamuel), [jorangreef](https://github.com/jorangreef), [jimmyhchan](https://github.com/jimmyhchan), [jameydeorio](https://github.com/jameydeorio), [jameskraus](https://github.com/jameskraus), [hyderali](https://github.com/hyderali), [hansottowirtz](https://github.com/hansottowirtz), [hackvertor](https://github.com/hackvertor), [freddyb](https://github.com/freddyb), [flavorjones](https://github.com/flavorjones), [djfarrelly](https://github.com/djfarrelly), [devd](https://github.com/devd), [camerondunford](https://github.com/camerondunford), [buu700](https://github.com/buu700), [buildog](https://github.com/buildog), [alabiaga](https://github.com/alabiaga), [Vector919](https://github.com/Vector919), [Robbert](https://github.com/Robbert), [GreLI](https://github.com/GreLI), [FuzzySockets](https://github.com/FuzzySockets), [ArtemBernatskyy](https://github.com/ArtemBernatskyy), [@garethheyes](https://twitter.com/garethheyes), [@shafigullin](https://twitter.com/shafigullin), [@mmrupp](https://twitter.com/mmrupp), [@irsdl](https://twitter.com/irsdl),[ShikariSenpai](https://github.com/ShikariSenpai), [ansjdnakjdnajkd](https://github.com/ansjdnakjdnajkd), [@asutherland](https://twitter.com/asutherland), [@mathias](https://twitter.com/mathias), [@cgvwzq](https://twitter.com/cgvwzq), [@robbertatwork](https://twitter.com/robbertatwork), [@giutro](https://twitter.com/giutro), [@CmdEngineer\_](https://twitter.com/CmdEngineer_), [@avr4mit](https://twitter.com/avr4mit) and especially [@securitymb ❤️](https://twitter.com/securitymb) & [@masatokinugawa ❤️](https://twitter.com/masatokinugawa) | ||
[JGraph 💸](https://github.com/jgraph), [Sentry 💸](https://github.com/getsentry), [jarrodldavis 💸](https://github.com/jarrodldavis), [GrantGryczan](https://github.com/GrantGryczan), [Lowdefy 💸](https://twitter.com/lowdefy), [granlem ](https://twitter.com/MaximeVeit), [oreoshake ](https://github.com/oreoshake), [dcramer 💸](https://github.com/dcramer),[tdeekens ❤️](https://github.com/tdeekens), [peernohell ❤️](https://github.com/peernohell), [is2ei](https://github.com/is2ei), [franktopel](https://github.com/franktopel), [NateScarlet](https://github.com/NateScarlet), [neilj](https://github.com/neilj), [fhemberger](https://github.com/fhemberger), [Joris-van-der-Wel](https://github.com/Joris-van-der-Wel), [ydaniv](https://github.com/ydaniv), [terjanq](https://twitter.com/terjanq), [filedescriptor](https://github.com/filedescriptor), [ConradIrwin](https://github.com/ConradIrwin), [gibson042](https://github.com/gibson042), [choumx](https://github.com/choumx), [0xSobky](https://github.com/0xSobky), [styfle](https://github.com/styfle), [koto](https://github.com/koto), [tlau88](https://github.com/tlau88), [strugee](https://github.com/strugee), [oparoz](https://github.com/oparoz), [mathiasbynens](https://github.com/mathiasbynens), [edg2s](https://github.com/edg2s), [dnkolegov](https://github.com/dnkolegov), [dhardtke](https://github.com/dhardtke), [wirehead](https://github.com/wirehead), [thorn0](https://github.com/thorn0), [styu](https://github.com/styu), [mozfreddyb](https://github.com/mozfreddyb), [mikesamuel](https://github.com/mikesamuel), [jorangreef](https://github.com/jorangreef), [jimmyhchan](https://github.com/jimmyhchan), [jameydeorio](https://github.com/jameydeorio), [jameskraus](https://github.com/jameskraus), [hyderali](https://github.com/hyderali), [hansottowirtz](https://github.com/hansottowirtz), [hackvertor](https://github.com/hackvertor), [freddyb](https://github.com/freddyb), [flavorjones](https://github.com/flavorjones), [djfarrelly](https://github.com/djfarrelly), [devd](https://github.com/devd), [camerondunford](https://github.com/camerondunford), [buu700](https://github.com/buu700), [buildog](https://github.com/buildog), [alabiaga](https://github.com/alabiaga), [Vector919](https://github.com/Vector919), [Robbert](https://github.com/Robbert), [GreLI](https://github.com/GreLI), [FuzzySockets](https://github.com/FuzzySockets), [ArtemBernatskyy](https://github.com/ArtemBernatskyy), [@garethheyes](https://twitter.com/garethheyes), [@shafigullin](https://twitter.com/shafigullin), [@mmrupp](https://twitter.com/mmrupp), [@irsdl](https://twitter.com/irsdl),[ShikariSenpai](https://github.com/ShikariSenpai), [ansjdnakjdnajkd](https://github.com/ansjdnakjdnajkd), [@asutherland](https://twitter.com/asutherland), [@mathias](https://twitter.com/mathias), [@cgvwzq](https://twitter.com/cgvwzq), [@robbertatwork](https://twitter.com/robbertatwork), [@giutro](https://twitter.com/giutro), [@CmdEngineer\_](https://twitter.com/CmdEngineer_), [@avr4mit](https://twitter.com/avr4mit) and especially [@securitymb ❤️](https://twitter.com/securitymb) & [@masatokinugawa ❤️](https://twitter.com/masatokinugawa) | ||
@@ -389,0 +389,0 @@ ## Testing powered by |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
675733
29
3930