umap-project 1.14.0a4__py3-none-any.whl → 2.0.0a0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of umap-project might be problematic. Click here for more details.

Files changed (226) hide show
  1. umap/__init__.py +1 -1
  2. umap/decorators.py +0 -14
  3. umap/locale/br/LC_MESSAGES/django.mo +0 -0
  4. umap/locale/br/LC_MESSAGES/django.po +137 -85
  5. umap/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
  6. umap/locale/cs_CZ/LC_MESSAGES/django.po +136 -84
  7. umap/locale/el/LC_MESSAGES/django.mo +0 -0
  8. umap/locale/el/LC_MESSAGES/django.po +136 -84
  9. umap/locale/en/LC_MESSAGES/django.po +128 -88
  10. umap/locale/es/LC_MESSAGES/django.mo +0 -0
  11. umap/locale/es/LC_MESSAGES/django.po +136 -84
  12. umap/locale/fr/LC_MESSAGES/django.mo +0 -0
  13. umap/locale/fr/LC_MESSAGES/django.po +131 -91
  14. umap/locale/hu/LC_MESSAGES/django.mo +0 -0
  15. umap/locale/hu/LC_MESSAGES/django.po +137 -85
  16. umap/locale/it/LC_MESSAGES/django.mo +0 -0
  17. umap/locale/it/LC_MESSAGES/django.po +136 -84
  18. umap/locale/ms/LC_MESSAGES/django.mo +0 -0
  19. umap/locale/ms/LC_MESSAGES/django.po +136 -84
  20. umap/locale/pl/LC_MESSAGES/django.mo +0 -0
  21. umap/locale/pl/LC_MESSAGES/django.po +136 -84
  22. umap/locale/sv/LC_MESSAGES/django.mo +0 -0
  23. umap/locale/sv/LC_MESSAGES/django.po +135 -83
  24. umap/locale/zh_TW/LC_MESSAGES/django.mo +0 -0
  25. umap/locale/zh_TW/LC_MESSAGES/django.po +143 -91
  26. umap/models.py +23 -1
  27. umap/settings/__init__.py +1 -4
  28. umap/settings/base.py +1 -0
  29. umap/static/umap/base.css +5 -0
  30. umap/static/umap/content.css +185 -13
  31. umap/static/umap/favicons/icon.svg +2 -2
  32. umap/static/umap/img/edit.svg +3 -3
  33. umap/static/umap/img/icon-delete.svg +4 -0
  34. umap/static/umap/img/icon-download.svg +13 -0
  35. umap/static/umap/img/icon-duplicate.svg +5 -0
  36. umap/static/umap/img/icon-edit.svg +12 -0
  37. umap/static/umap/img/icon-share.svg +11 -0
  38. umap/static/umap/img/icon-view.svg +12 -0
  39. umap/static/umap/img/logo.svg +2 -2
  40. umap/static/umap/img/logo_small.svg +2 -2
  41. umap/static/umap/img/marker.svg +4 -0
  42. umap/static/umap/img/opensource.svg +2 -2
  43. umap/static/umap/img/osm.svg +2 -2
  44. umap/static/umap/js/components/fragment.js +1 -1
  45. umap/static/umap/js/modules/browser.js +159 -0
  46. umap/static/umap/js/modules/global.js +3 -1
  47. umap/static/umap/js/modules/request.js +155 -0
  48. umap/static/umap/js/umap.autocomplete.js +28 -38
  49. umap/static/umap/js/umap.controls.js +73 -58
  50. umap/static/umap/js/umap.core.js +4 -9
  51. umap/static/umap/js/umap.datalayer.permissions.js +13 -12
  52. umap/static/umap/js/umap.features.js +51 -49
  53. umap/static/umap/js/umap.forms.js +19 -19
  54. umap/static/umap/js/umap.icon.js +17 -17
  55. umap/static/umap/js/umap.importer.js +2 -1
  56. umap/static/umap/js/umap.js +242 -291
  57. umap/static/umap/js/umap.layer.js +173 -140
  58. umap/static/umap/js/umap.permissions.js +24 -25
  59. umap/static/umap/js/umap.popup.js +14 -14
  60. umap/static/umap/js/umap.share.js +4 -4
  61. umap/static/umap/js/umap.slideshow.js +4 -4
  62. umap/static/umap/js/umap.tableeditor.js +2 -2
  63. umap/static/umap/js/umap.ui.js +1 -1
  64. umap/static/umap/locale/am_ET.js +1 -11
  65. umap/static/umap/locale/am_ET.json +1 -11
  66. umap/static/umap/locale/ar.js +1 -11
  67. umap/static/umap/locale/ar.json +1 -11
  68. umap/static/umap/locale/ast.js +1 -11
  69. umap/static/umap/locale/ast.json +1 -11
  70. umap/static/umap/locale/bg.js +1 -11
  71. umap/static/umap/locale/bg.json +1 -11
  72. umap/static/umap/locale/br.js +1 -11
  73. umap/static/umap/locale/br.json +1 -11
  74. umap/static/umap/locale/ca.js +1 -11
  75. umap/static/umap/locale/ca.json +1 -11
  76. umap/static/umap/locale/cs_CZ.js +1 -11
  77. umap/static/umap/locale/cs_CZ.json +1 -11
  78. umap/static/umap/locale/da.js +1 -11
  79. umap/static/umap/locale/da.json +1 -11
  80. umap/static/umap/locale/de.js +1 -11
  81. umap/static/umap/locale/de.json +1 -11
  82. umap/static/umap/locale/el.js +1 -11
  83. umap/static/umap/locale/el.json +1 -11
  84. umap/static/umap/locale/en.js +1 -11
  85. umap/static/umap/locale/en.json +1 -11
  86. umap/static/umap/locale/en_US.json +1 -11
  87. umap/static/umap/locale/es.js +1 -11
  88. umap/static/umap/locale/es.json +1 -11
  89. umap/static/umap/locale/et.js +1 -11
  90. umap/static/umap/locale/et.json +1 -11
  91. umap/static/umap/locale/fa_IR.js +6 -16
  92. umap/static/umap/locale/fa_IR.json +6 -16
  93. umap/static/umap/locale/fi.js +1 -11
  94. umap/static/umap/locale/fi.json +1 -11
  95. umap/static/umap/locale/fr.js +1 -11
  96. umap/static/umap/locale/fr.json +1 -11
  97. umap/static/umap/locale/gl.js +1 -11
  98. umap/static/umap/locale/gl.json +1 -11
  99. umap/static/umap/locale/he.js +1 -11
  100. umap/static/umap/locale/he.json +1 -11
  101. umap/static/umap/locale/hr.js +1 -11
  102. umap/static/umap/locale/hr.json +1 -11
  103. umap/static/umap/locale/hu.js +1 -11
  104. umap/static/umap/locale/hu.json +1 -11
  105. umap/static/umap/locale/id.js +1 -11
  106. umap/static/umap/locale/id.json +1 -11
  107. umap/static/umap/locale/is.js +1 -11
  108. umap/static/umap/locale/is.json +1 -11
  109. umap/static/umap/locale/it.js +1 -11
  110. umap/static/umap/locale/it.json +1 -11
  111. umap/static/umap/locale/ja.js +1 -11
  112. umap/static/umap/locale/ja.json +1 -11
  113. umap/static/umap/locale/ko.js +1 -11
  114. umap/static/umap/locale/ko.json +1 -11
  115. umap/static/umap/locale/lt.js +1 -11
  116. umap/static/umap/locale/lt.json +1 -11
  117. umap/static/umap/locale/ms.js +1 -11
  118. umap/static/umap/locale/ms.json +1 -11
  119. umap/static/umap/locale/nl.js +1 -11
  120. umap/static/umap/locale/nl.json +1 -11
  121. umap/static/umap/locale/no.js +1 -11
  122. umap/static/umap/locale/no.json +1 -11
  123. umap/static/umap/locale/pl.js +1 -11
  124. umap/static/umap/locale/pl.json +1 -11
  125. umap/static/umap/locale/pl_PL.json +1 -11
  126. umap/static/umap/locale/pt.js +1 -11
  127. umap/static/umap/locale/pt.json +1 -11
  128. umap/static/umap/locale/pt_BR.js +1 -11
  129. umap/static/umap/locale/pt_BR.json +1 -11
  130. umap/static/umap/locale/pt_PT.js +1 -11
  131. umap/static/umap/locale/pt_PT.json +1 -11
  132. umap/static/umap/locale/ro.js +1 -11
  133. umap/static/umap/locale/ro.json +1 -11
  134. umap/static/umap/locale/ru.js +1 -11
  135. umap/static/umap/locale/ru.json +1 -11
  136. umap/static/umap/locale/sk_SK.js +1 -11
  137. umap/static/umap/locale/sk_SK.json +1 -11
  138. umap/static/umap/locale/sl.js +1 -11
  139. umap/static/umap/locale/sl.json +1 -11
  140. umap/static/umap/locale/sr.js +1 -11
  141. umap/static/umap/locale/sr.json +1 -11
  142. umap/static/umap/locale/sv.js +1 -11
  143. umap/static/umap/locale/sv.json +1 -11
  144. umap/static/umap/locale/th_TH.js +1 -11
  145. umap/static/umap/locale/th_TH.json +1 -11
  146. umap/static/umap/locale/tr.js +1 -11
  147. umap/static/umap/locale/tr.json +1 -11
  148. umap/static/umap/locale/uk_UA.js +1 -11
  149. umap/static/umap/locale/uk_UA.json +1 -11
  150. umap/static/umap/locale/vi.js +1 -11
  151. umap/static/umap/locale/vi.json +1 -11
  152. umap/static/umap/locale/vi_VN.json +1 -11
  153. umap/static/umap/locale/zh.js +1 -11
  154. umap/static/umap/locale/zh.json +1 -11
  155. umap/static/umap/locale/zh_CN.json +1 -11
  156. umap/static/umap/locale/zh_TW.Big5.json +1 -11
  157. umap/static/umap/locale/zh_TW.js +17 -27
  158. umap/static/umap/locale/zh_TW.json +17 -27
  159. umap/static/umap/map.css +2 -2
  160. umap/static/umap/nav.css +2 -1
  161. umap/static/umap/test/.eslintrc +0 -1
  162. umap/static/umap/test/Choropleth.js +29 -27
  163. umap/static/umap/test/DataLayer.js +207 -239
  164. umap/static/umap/test/Feature.js +33 -58
  165. umap/static/umap/test/Map.Export.js +11 -11
  166. umap/static/umap/test/Map.js +66 -67
  167. umap/static/umap/test/Marker.js +36 -32
  168. umap/static/umap/test/Polygon.js +95 -95
  169. umap/static/umap/test/Polyline.js +31 -31
  170. umap/static/umap/test/TableEditor.js +29 -25
  171. umap/static/umap/test/_pre.js +2 -7
  172. umap/static/umap/test/index.html +4 -4
  173. umap/static/umap/vendors/contextmenu/leaflet.contextmenu.css +54 -0
  174. umap/static/umap/vendors/contextmenu/leaflet.contextmenu.js +586 -0
  175. umap/static/umap/vendors/csv2geojson/index.js +259 -0
  176. umap/static/umap/vendors/dompurify/purify.js +1633 -0
  177. umap/static/umap/vendors/locatecontrol/L.Control.Locate.css +63 -0
  178. umap/static/umap/vendors/locatecontrol/L.Control.Locate.js +950 -0
  179. umap/static/umap/vendors/minimap/Control.MiniMap.css +88 -0
  180. umap/static/umap/vendors/minimap/Control.MiniMap.js +352 -0
  181. umap/static/umap/vendors/togeojson/togeojson.js +2 -0
  182. umap/templates/auth/user_form.html +3 -2
  183. umap/templates/base.html +1 -0
  184. umap/templates/registration/login.html +51 -36
  185. umap/templates/umap/about_summary.html +1 -1
  186. umap/templates/umap/branding.html +3 -0
  187. umap/templates/umap/content.html +15 -39
  188. umap/templates/umap/header.html +0 -0
  189. umap/templates/umap/home.html +4 -2
  190. umap/templates/umap/js.html +0 -1
  191. umap/templates/umap/map_detail.html +9 -0
  192. umap/templates/umap/map_init.html +1 -1
  193. umap/templates/umap/map_messages.html +4 -2
  194. umap/templates/umap/map_table.html +130 -69
  195. umap/templates/umap/navigation.html +2 -4
  196. umap/templates/umap/user_dashboard.html +29 -6
  197. umap/tests/base.py +1 -1
  198. umap/tests/integration/conftest.py +18 -0
  199. umap/tests/integration/test_anonymous_owned_map.py +6 -3
  200. umap/tests/integration/test_browser.py +166 -6
  201. umap/tests/integration/test_collaborative_editing.py +142 -0
  202. umap/tests/integration/test_dashboard.py +17 -0
  203. umap/tests/integration/test_edit_datalayer.py +4 -3
  204. umap/tests/integration/test_export_map.py +1 -1
  205. umap/tests/integration/test_import.py +9 -4
  206. umap/tests/integration/test_map.py +64 -0
  207. umap/tests/integration/test_map_preview.py +75 -0
  208. umap/tests/integration/test_owned_map.py +11 -25
  209. umap/tests/integration/test_picto.py +3 -3
  210. umap/tests/integration/test_querystring.py +52 -0
  211. umap/tests/integration/test_share.py +22 -0
  212. umap/tests/test_map_views.py +157 -14
  213. umap/tests/test_merge_features.py +5 -5
  214. umap/tests/test_views.py +50 -11
  215. umap/urls.py +6 -12
  216. umap/utils.py +1 -1
  217. umap/views.py +170 -47
  218. {umap_project-1.14.0a4.dist-info → umap_project-2.0.0a0.dist-info}/METADATA +13 -15
  219. {umap_project-1.14.0a4.dist-info → umap_project-2.0.0a0.dist-info}/RECORD +222 -200
  220. umap/static/umap/js/umap.browser.js +0 -148
  221. umap/static/umap/js/umap.xhr.js +0 -304
  222. umap/static/umap/test/Controls.js +0 -100
  223. umap/static/umap/test/Map.Init.js +0 -46
  224. {umap_project-1.14.0a4.dist-info → umap_project-2.0.0a0.dist-info}/WHEEL +0 -0
  225. {umap_project-1.14.0a4.dist-info → umap_project-2.0.0a0.dist-info}/entry_points.txt +0 -0
  226. {umap_project-1.14.0a4.dist-info → umap_project-2.0.0a0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,1633 @@
1
+ /*! @license DOMPurify 3.0.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.3/LICENSE */
2
+
3
+ (function (global, factory) {
4
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
5
+ typeof define === 'function' && define.amd ? define(factory) :
6
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.DOMPurify = factory());
7
+ })(this, (function () { 'use strict';
8
+
9
+ const {
10
+ entries,
11
+ setPrototypeOf,
12
+ isFrozen,
13
+ getPrototypeOf,
14
+ getOwnPropertyDescriptor
15
+ } = Object;
16
+ let {
17
+ freeze,
18
+ seal,
19
+ create
20
+ } = Object; // eslint-disable-line import/no-mutable-exports
21
+
22
+ let {
23
+ apply,
24
+ construct
25
+ } = typeof Reflect !== 'undefined' && Reflect;
26
+
27
+ if (!apply) {
28
+ apply = function apply(fun, thisValue, args) {
29
+ return fun.apply(thisValue, args);
30
+ };
31
+ }
32
+
33
+ if (!freeze) {
34
+ freeze = function freeze(x) {
35
+ return x;
36
+ };
37
+ }
38
+
39
+ if (!seal) {
40
+ seal = function seal(x) {
41
+ return x;
42
+ };
43
+ }
44
+
45
+ if (!construct) {
46
+ construct = function construct(Func, args) {
47
+ return new Func(...args);
48
+ };
49
+ }
50
+
51
+ const arrayForEach = unapply(Array.prototype.forEach);
52
+ const arrayPop = unapply(Array.prototype.pop);
53
+ const arrayPush = unapply(Array.prototype.push);
54
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
55
+ const stringToString = unapply(String.prototype.toString);
56
+ const stringMatch = unapply(String.prototype.match);
57
+ const stringReplace = unapply(String.prototype.replace);
58
+ const stringIndexOf = unapply(String.prototype.indexOf);
59
+ const stringTrim = unapply(String.prototype.trim);
60
+ const regExpTest = unapply(RegExp.prototype.test);
61
+ const typeErrorCreate = unconstruct(TypeError);
62
+ function unapply(func) {
63
+ return function (thisArg) {
64
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
65
+ args[_key - 1] = arguments[_key];
66
+ }
67
+
68
+ return apply(func, thisArg, args);
69
+ };
70
+ }
71
+ function unconstruct(func) {
72
+ return function () {
73
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
74
+ args[_key2] = arguments[_key2];
75
+ }
76
+
77
+ return construct(func, args);
78
+ };
79
+ }
80
+ /* Add properties to a lookup table */
81
+
82
+ function addToSet(set, array, transformCaseFunc) {
83
+ var _transformCaseFunc;
84
+
85
+ transformCaseFunc = (_transformCaseFunc = transformCaseFunc) !== null && _transformCaseFunc !== void 0 ? _transformCaseFunc : stringToLowerCase;
86
+
87
+ if (setPrototypeOf) {
88
+ // Make 'in' and truthy checks like Boolean(set.constructor)
89
+ // independent of any properties defined on Object.prototype.
90
+ // Prevent prototype setters from intercepting set as a this value.
91
+ setPrototypeOf(set, null);
92
+ }
93
+
94
+ let l = array.length;
95
+
96
+ while (l--) {
97
+ let element = array[l];
98
+
99
+ if (typeof element === 'string') {
100
+ const lcElement = transformCaseFunc(element);
101
+
102
+ if (lcElement !== element) {
103
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
104
+ if (!isFrozen(array)) {
105
+ array[l] = lcElement;
106
+ }
107
+
108
+ element = lcElement;
109
+ }
110
+ }
111
+
112
+ set[element] = true;
113
+ }
114
+
115
+ return set;
116
+ }
117
+ /* Shallow clone an object */
118
+
119
+ function clone(object) {
120
+ const newObject = create(null);
121
+
122
+ for (const [property, value] of entries(object)) {
123
+ newObject[property] = value;
124
+ }
125
+
126
+ return newObject;
127
+ }
128
+ /* This method automatically checks if the prop is function
129
+ * or getter and behaves accordingly. */
130
+
131
+ function lookupGetter(object, prop) {
132
+ while (object !== null) {
133
+ const desc = getOwnPropertyDescriptor(object, prop);
134
+
135
+ if (desc) {
136
+ if (desc.get) {
137
+ return unapply(desc.get);
138
+ }
139
+
140
+ if (typeof desc.value === 'function') {
141
+ return unapply(desc.value);
142
+ }
143
+ }
144
+
145
+ object = getPrototypeOf(object);
146
+ }
147
+
148
+ function fallbackValue(element) {
149
+ console.warn('fallback value for', element);
150
+ return null;
151
+ }
152
+
153
+ return fallbackValue;
154
+ }
155
+
156
+ const 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
157
+
158
+ const 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']);
159
+ const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', '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.
160
+ // We still need to know them so that we can do namespace
161
+ // checks properly in case one wants to add them to
162
+ // allow-list.
163
+
164
+ const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', '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']);
165
+ const 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', 'mprescripts']); // Similarly to SVG, we want to know all MathML elements,
166
+ // even those that we disallow by default.
167
+
168
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
169
+ const text = freeze(['#text']);
170
+
171
+ const 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']);
172
+ const 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']);
173
+ const 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']);
174
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
175
+
176
+ const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
177
+
178
+ const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
179
+ const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
180
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
181
+
182
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
183
+
184
+ const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
185
+ );
186
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
187
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
188
+ );
189
+ const DOCTYPE_NAME = seal(/^html$/i);
190
+
191
+ var EXPRESSIONS = /*#__PURE__*/Object.freeze({
192
+ __proto__: null,
193
+ MUSTACHE_EXPR: MUSTACHE_EXPR,
194
+ ERB_EXPR: ERB_EXPR,
195
+ TMPLIT_EXPR: TMPLIT_EXPR,
196
+ DATA_ATTR: DATA_ATTR,
197
+ ARIA_ATTR: ARIA_ATTR,
198
+ IS_ALLOWED_URI: IS_ALLOWED_URI,
199
+ IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
200
+ ATTR_WHITESPACE: ATTR_WHITESPACE,
201
+ DOCTYPE_NAME: DOCTYPE_NAME
202
+ });
203
+
204
+ const getGlobal = () => typeof window === 'undefined' ? null : window;
205
+ /**
206
+ * Creates a no-op policy for internal use only.
207
+ * Don't export this function outside this module!
208
+ * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
209
+ * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
210
+ * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
211
+ * are not supported or creating the policy failed).
212
+ */
213
+
214
+
215
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
216
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
217
+ return null;
218
+ } // Allow the callers to control the unique policy name
219
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
220
+ // Policy creation with duplicate names throws in Trusted Types.
221
+
222
+
223
+ let suffix = null;
224
+ const ATTR_NAME = 'data-tt-policy-suffix';
225
+
226
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
227
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
228
+ }
229
+
230
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
231
+
232
+ try {
233
+ return trustedTypes.createPolicy(policyName, {
234
+ createHTML(html) {
235
+ return html;
236
+ },
237
+
238
+ createScriptURL(scriptUrl) {
239
+ return scriptUrl;
240
+ }
241
+
242
+ });
243
+ } catch (_) {
244
+ // Policy creation failed (most likely another DOMPurify script has
245
+ // already run). Skip creating the policy, as this will only cause errors
246
+ // if TT are enforced.
247
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
248
+ return null;
249
+ }
250
+ };
251
+
252
+ function createDOMPurify() {
253
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
254
+
255
+ const DOMPurify = root => createDOMPurify(root);
256
+ /**
257
+ * Version label, exposed for easier checks
258
+ * if DOMPurify is up to date or not
259
+ */
260
+
261
+
262
+ DOMPurify.version = '3.0.3';
263
+ /**
264
+ * Array of elements that DOMPurify removed during sanitation.
265
+ * Empty if nothing was removed.
266
+ */
267
+
268
+ DOMPurify.removed = [];
269
+
270
+ if (!window || !window.document || window.document.nodeType !== 9) {
271
+ // Not running in a browser, provide a factory function
272
+ // so that you can pass your own Window
273
+ DOMPurify.isSupported = false;
274
+ return DOMPurify;
275
+ }
276
+
277
+ const originalDocument = window.document;
278
+ const currentScript = originalDocument.currentScript;
279
+ let {
280
+ document
281
+ } = window;
282
+ const {
283
+ DocumentFragment,
284
+ HTMLTemplateElement,
285
+ Node,
286
+ Element,
287
+ NodeFilter,
288
+ NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
289
+ HTMLFormElement,
290
+ DOMParser,
291
+ trustedTypes
292
+ } = window;
293
+ const ElementPrototype = Element.prototype;
294
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
295
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
296
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
297
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a
298
+ // new document created via createHTMLDocument. As per the spec
299
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
300
+ // a new empty registry is used when creating a template contents owner
301
+ // document, so we use that as our parent document to ensure nothing
302
+ // is inherited.
303
+
304
+ if (typeof HTMLTemplateElement === 'function') {
305
+ const template = document.createElement('template');
306
+
307
+ if (template.content && template.content.ownerDocument) {
308
+ document = template.content.ownerDocument;
309
+ }
310
+ }
311
+
312
+ let trustedTypesPolicy;
313
+ let emptyHTML = '';
314
+ const {
315
+ implementation,
316
+ createNodeIterator,
317
+ createDocumentFragment,
318
+ getElementsByTagName
319
+ } = document;
320
+ const {
321
+ importNode
322
+ } = originalDocument;
323
+ let hooks = {};
324
+ /**
325
+ * Expose whether this browser supports running the full DOMPurify.
326
+ */
327
+
328
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
329
+ const {
330
+ MUSTACHE_EXPR,
331
+ ERB_EXPR,
332
+ TMPLIT_EXPR,
333
+ DATA_ATTR,
334
+ ARIA_ATTR,
335
+ IS_SCRIPT_OR_DATA,
336
+ ATTR_WHITESPACE
337
+ } = EXPRESSIONS;
338
+ let {
339
+ IS_ALLOWED_URI: IS_ALLOWED_URI$1
340
+ } = EXPRESSIONS;
341
+ /**
342
+ * We consider the elements and attributes below to be safe. Ideally
343
+ * don't add any new ones but feel free to remove unwanted ones.
344
+ */
345
+
346
+ /* allowed element names */
347
+
348
+ let ALLOWED_TAGS = null;
349
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
350
+ /* Allowed attribute names */
351
+
352
+ let ALLOWED_ATTR = null;
353
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
354
+ /*
355
+ * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
356
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
357
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
358
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
359
+ */
360
+
361
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {
362
+ tagNameCheck: {
363
+ writable: true,
364
+ configurable: false,
365
+ enumerable: true,
366
+ value: null
367
+ },
368
+ attributeNameCheck: {
369
+ writable: true,
370
+ configurable: false,
371
+ enumerable: true,
372
+ value: null
373
+ },
374
+ allowCustomizedBuiltInElements: {
375
+ writable: true,
376
+ configurable: false,
377
+ enumerable: true,
378
+ value: false
379
+ }
380
+ }));
381
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
382
+
383
+ let FORBID_TAGS = null;
384
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
385
+
386
+ let FORBID_ATTR = null;
387
+ /* Decide if ARIA attributes are okay */
388
+
389
+ let ALLOW_ARIA_ATTR = true;
390
+ /* Decide if custom data attributes are okay */
391
+
392
+ let ALLOW_DATA_ATTR = true;
393
+ /* Decide if unknown protocols are okay */
394
+
395
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
396
+ /* Decide if self-closing tags in attributes are allowed.
397
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
398
+
399
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
400
+ /* Output should be safe for common template engines.
401
+ * This means, DOMPurify removes data attributes, mustaches and ERB
402
+ */
403
+
404
+ let SAFE_FOR_TEMPLATES = false;
405
+ /* Decide if document with <html>... should be returned */
406
+
407
+ let WHOLE_DOCUMENT = false;
408
+ /* Track whether config is already set on this instance of DOMPurify. */
409
+
410
+ let SET_CONFIG = false;
411
+ /* Decide if all elements (e.g. style, script) must be children of
412
+ * document.body. By default, browsers might move them to document.head */
413
+
414
+ let FORCE_BODY = false;
415
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
416
+ * string (or a TrustedHTML object if Trusted Types are supported).
417
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
418
+ */
419
+
420
+ let RETURN_DOM = false;
421
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
422
+ * string (or a TrustedHTML object if Trusted Types are supported) */
423
+
424
+ let RETURN_DOM_FRAGMENT = false;
425
+ /* Try to return a Trusted Type object instead of a string, return a string in
426
+ * case Trusted Types are not supported */
427
+
428
+ let RETURN_TRUSTED_TYPE = false;
429
+ /* Output should be free from DOM clobbering attacks?
430
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
431
+ */
432
+
433
+ let SANITIZE_DOM = true;
434
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
435
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
436
+ *
437
+ * HTML/DOM spec rules that enable DOM Clobbering:
438
+ * - Named Access on Window (§7.3.3)
439
+ * - DOM Tree Accessors (§3.1.5)
440
+ * - Form Element Parent-Child Relations (§4.10.3)
441
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
442
+ * - HTMLCollection (§4.2.10.2)
443
+ *
444
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
445
+ * with a constant string, i.e., `user-content-`
446
+ */
447
+
448
+ let SANITIZE_NAMED_PROPS = false;
449
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
450
+ /* Keep element content when removing element? */
451
+
452
+ let KEEP_CONTENT = true;
453
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
454
+ * of importing it into a new Document and returning a sanitized copy */
455
+
456
+ let IN_PLACE = false;
457
+ /* Allow usage of profiles like html, svg and mathMl */
458
+
459
+ let USE_PROFILES = {};
460
+ /* Tags to ignore content of when KEEP_CONTENT is true */
461
+
462
+ let FORBID_CONTENTS = null;
463
+ const 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']);
464
+ /* Tags that are safe for data: URIs */
465
+
466
+ let DATA_URI_TAGS = null;
467
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
468
+ /* Attributes safe for values like "javascript:" */
469
+
470
+ let URI_SAFE_ATTRIBUTES = null;
471
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
472
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
473
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
474
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
475
+ /* Document namespace */
476
+
477
+ let NAMESPACE = HTML_NAMESPACE;
478
+ let IS_EMPTY_INPUT = false;
479
+ /* Allowed XHTML+XML namespaces */
480
+
481
+ let ALLOWED_NAMESPACES = null;
482
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
483
+ /* Parsing of strict XHTML documents */
484
+
485
+ let PARSER_MEDIA_TYPE;
486
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
487
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
488
+ let transformCaseFunc;
489
+ /* Keep a reference to config to pass to hooks */
490
+
491
+ let CONFIG = null;
492
+ /* Ideally, do not touch anything below this line */
493
+
494
+ /* ______________________________________________ */
495
+
496
+ const formElement = document.createElement('form');
497
+
498
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
499
+ return testValue instanceof RegExp || testValue instanceof Function;
500
+ };
501
+ /**
502
+ * _parseConfig
503
+ *
504
+ * @param {Object} cfg optional config literal
505
+ */
506
+ // eslint-disable-next-line complexity
507
+
508
+
509
+ const _parseConfig = function _parseConfig(cfg) {
510
+ if (CONFIG && CONFIG === cfg) {
511
+ return;
512
+ }
513
+ /* Shield configuration object from tampering */
514
+
515
+
516
+ if (!cfg || typeof cfg !== 'object') {
517
+ cfg = {};
518
+ }
519
+ /* Shield configuration object from prototype pollution */
520
+
521
+
522
+ cfg = clone(cfg);
523
+ PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
524
+ 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.
525
+
526
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
527
+ /* Set configuration parameters */
528
+
529
+ ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
530
+ ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
531
+ ALLOWED_NAMESPACES = 'ALLOWED_NAMESPACES' in cfg ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
532
+ URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), // eslint-disable-line indent
533
+ cfg.ADD_URI_SAFE_ATTR, // eslint-disable-line indent
534
+ transformCaseFunc // eslint-disable-line indent
535
+ ) // eslint-disable-line indent
536
+ : DEFAULT_URI_SAFE_ATTRIBUTES;
537
+ DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), // eslint-disable-line indent
538
+ cfg.ADD_DATA_URI_TAGS, // eslint-disable-line indent
539
+ transformCaseFunc // eslint-disable-line indent
540
+ ) // eslint-disable-line indent
541
+ : DEFAULT_DATA_URI_TAGS;
542
+ FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
543
+ FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
544
+ FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
545
+ USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
546
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
547
+
548
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
549
+
550
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
551
+
552
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
553
+
554
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
555
+
556
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
557
+
558
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
559
+
560
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
561
+
562
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
563
+
564
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
565
+
566
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
567
+
568
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
569
+
570
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
571
+
572
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
573
+
574
+ IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
575
+ NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
576
+ CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
577
+
578
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
579
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
580
+ }
581
+
582
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
583
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
584
+ }
585
+
586
+ if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
587
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
588
+ }
589
+
590
+ if (SAFE_FOR_TEMPLATES) {
591
+ ALLOW_DATA_ATTR = false;
592
+ }
593
+
594
+ if (RETURN_DOM_FRAGMENT) {
595
+ RETURN_DOM = true;
596
+ }
597
+ /* Parse profile info */
598
+
599
+
600
+ if (USE_PROFILES) {
601
+ ALLOWED_TAGS = addToSet({}, [...text]);
602
+ ALLOWED_ATTR = [];
603
+
604
+ if (USE_PROFILES.html === true) {
605
+ addToSet(ALLOWED_TAGS, html$1);
606
+ addToSet(ALLOWED_ATTR, html);
607
+ }
608
+
609
+ if (USE_PROFILES.svg === true) {
610
+ addToSet(ALLOWED_TAGS, svg$1);
611
+ addToSet(ALLOWED_ATTR, svg);
612
+ addToSet(ALLOWED_ATTR, xml);
613
+ }
614
+
615
+ if (USE_PROFILES.svgFilters === true) {
616
+ addToSet(ALLOWED_TAGS, svgFilters);
617
+ addToSet(ALLOWED_ATTR, svg);
618
+ addToSet(ALLOWED_ATTR, xml);
619
+ }
620
+
621
+ if (USE_PROFILES.mathMl === true) {
622
+ addToSet(ALLOWED_TAGS, mathMl$1);
623
+ addToSet(ALLOWED_ATTR, mathMl);
624
+ addToSet(ALLOWED_ATTR, xml);
625
+ }
626
+ }
627
+ /* Merge configuration parameters */
628
+
629
+
630
+ if (cfg.ADD_TAGS) {
631
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
632
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
633
+ }
634
+
635
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
636
+ }
637
+
638
+ if (cfg.ADD_ATTR) {
639
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
640
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
641
+ }
642
+
643
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
644
+ }
645
+
646
+ if (cfg.ADD_URI_SAFE_ATTR) {
647
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
648
+ }
649
+
650
+ if (cfg.FORBID_CONTENTS) {
651
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
652
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
653
+ }
654
+
655
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
656
+ }
657
+ /* Add #text in case KEEP_CONTENT is set to true */
658
+
659
+
660
+ if (KEEP_CONTENT) {
661
+ ALLOWED_TAGS['#text'] = true;
662
+ }
663
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
664
+
665
+
666
+ if (WHOLE_DOCUMENT) {
667
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
668
+ }
669
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
670
+
671
+
672
+ if (ALLOWED_TAGS.table) {
673
+ addToSet(ALLOWED_TAGS, ['tbody']);
674
+ delete FORBID_TAGS.tbody;
675
+ }
676
+
677
+ if (cfg.TRUSTED_TYPES_POLICY) {
678
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
679
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
680
+ }
681
+
682
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
683
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
684
+ } // Overwrite existing TrustedTypes policy.
685
+
686
+
687
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; // Sign local variables required by `sanitize`.
688
+
689
+ emptyHTML = trustedTypesPolicy.createHTML('');
690
+ } else {
691
+ // Uninitialized policy, attempt to initialize the internal dompurify policy.
692
+ if (trustedTypesPolicy === undefined) {
693
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
694
+ } // If creating the internal policy succeeded sign internal variables.
695
+
696
+
697
+ if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
698
+ emptyHTML = trustedTypesPolicy.createHTML('');
699
+ }
700
+ } // Prevent further manipulation of configuration.
701
+ // Not available in IE8, Safari 5, etc.
702
+
703
+
704
+ if (freeze) {
705
+ freeze(cfg);
706
+ }
707
+
708
+ CONFIG = cfg;
709
+ };
710
+
711
+ const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
712
+ const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); // Certain elements are allowed in both SVG and HTML
713
+ // namespace. We need to specify them explicitly
714
+ // so that they don't get erroneously deleted from
715
+ // HTML namespace.
716
+
717
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
718
+ /* Keep track of all possible SVG and MathML tags
719
+ * so that we can perform the namespace checks
720
+ * correctly. */
721
+
722
+ const ALL_SVG_TAGS = addToSet({}, svg$1);
723
+ addToSet(ALL_SVG_TAGS, svgFilters);
724
+ addToSet(ALL_SVG_TAGS, svgDisallowed);
725
+ const ALL_MATHML_TAGS = addToSet({}, mathMl$1);
726
+ addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
727
+ /**
728
+ *
729
+ *
730
+ * @param {Element} element a DOM element whose namespace is being checked
731
+ * @returns {boolean} Return false if the element has a
732
+ * namespace that a spec-compliant parser would never
733
+ * return. Return true otherwise.
734
+ */
735
+
736
+ const _checkValidNamespace = function _checkValidNamespace(element) {
737
+ let parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode
738
+ // can be null. We just simulate parent in this case.
739
+
740
+ if (!parent || !parent.tagName) {
741
+ parent = {
742
+ namespaceURI: NAMESPACE,
743
+ tagName: 'template'
744
+ };
745
+ }
746
+
747
+ const tagName = stringToLowerCase(element.tagName);
748
+ const parentTagName = stringToLowerCase(parent.tagName);
749
+
750
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
751
+ return false;
752
+ }
753
+
754
+ if (element.namespaceURI === SVG_NAMESPACE) {
755
+ // The only way to switch from HTML namespace to SVG
756
+ // is via <svg>. If it happens via any other tag, then
757
+ // it should be killed.
758
+ if (parent.namespaceURI === HTML_NAMESPACE) {
759
+ return tagName === 'svg';
760
+ } // The only way to switch from MathML to SVG is via`
761
+ // svg if parent is either <annotation-xml> or MathML
762
+ // text integration points.
763
+
764
+
765
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
766
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
767
+ } // We only allow elements that are defined in SVG
768
+ // spec. All others are disallowed in SVG namespace.
769
+
770
+
771
+ return Boolean(ALL_SVG_TAGS[tagName]);
772
+ }
773
+
774
+ if (element.namespaceURI === MATHML_NAMESPACE) {
775
+ // The only way to switch from HTML namespace to MathML
776
+ // is via <math>. If it happens via any other tag, then
777
+ // it should be killed.
778
+ if (parent.namespaceURI === HTML_NAMESPACE) {
779
+ return tagName === 'math';
780
+ } // The only way to switch from SVG to MathML is via
781
+ // <math> and HTML integration points
782
+
783
+
784
+ if (parent.namespaceURI === SVG_NAMESPACE) {
785
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
786
+ } // We only allow elements that are defined in MathML
787
+ // spec. All others are disallowed in MathML namespace.
788
+
789
+
790
+ return Boolean(ALL_MATHML_TAGS[tagName]);
791
+ }
792
+
793
+ if (element.namespaceURI === HTML_NAMESPACE) {
794
+ // The only way to switch from SVG to HTML is via
795
+ // HTML integration points, and from MathML to HTML
796
+ // is via MathML text integration points
797
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
798
+ return false;
799
+ }
800
+
801
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
802
+ return false;
803
+ } // We disallow tags that are specific for MathML
804
+ // or SVG and should never appear in HTML namespace
805
+
806
+
807
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
808
+ } // For XHTML and XML documents that support custom namespaces
809
+
810
+
811
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
812
+ return true;
813
+ } // The code should never reach this place (this means
814
+ // that the element somehow got namespace that is not
815
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
816
+ // Return false just in case.
817
+
818
+
819
+ return false;
820
+ };
821
+ /**
822
+ * _forceRemove
823
+ *
824
+ * @param {Node} node a DOM node
825
+ */
826
+
827
+
828
+ const _forceRemove = function _forceRemove(node) {
829
+ arrayPush(DOMPurify.removed, {
830
+ element: node
831
+ });
832
+
833
+ try {
834
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
835
+ node.parentNode.removeChild(node);
836
+ } catch (_) {
837
+ node.remove();
838
+ }
839
+ };
840
+ /**
841
+ * _removeAttribute
842
+ *
843
+ * @param {String} name an Attribute name
844
+ * @param {Node} node a DOM node
845
+ */
846
+
847
+
848
+ const _removeAttribute = function _removeAttribute(name, node) {
849
+ try {
850
+ arrayPush(DOMPurify.removed, {
851
+ attribute: node.getAttributeNode(name),
852
+ from: node
853
+ });
854
+ } catch (_) {
855
+ arrayPush(DOMPurify.removed, {
856
+ attribute: null,
857
+ from: node
858
+ });
859
+ }
860
+
861
+ node.removeAttribute(name); // We void attribute values for unremovable "is"" attributes
862
+
863
+ if (name === 'is' && !ALLOWED_ATTR[name]) {
864
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
865
+ try {
866
+ _forceRemove(node);
867
+ } catch (_) {}
868
+ } else {
869
+ try {
870
+ node.setAttribute(name, '');
871
+ } catch (_) {}
872
+ }
873
+ }
874
+ };
875
+ /**
876
+ * _initDocument
877
+ *
878
+ * @param {String} dirty a string of dirty markup
879
+ * @return {Document} a DOM, filled with the dirty markup
880
+ */
881
+
882
+
883
+ const _initDocument = function _initDocument(dirty) {
884
+ /* Create a HTML document */
885
+ let doc;
886
+ let leadingWhitespace;
887
+
888
+ if (FORCE_BODY) {
889
+ dirty = '<remove></remove>' + dirty;
890
+ } else {
891
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
892
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
893
+ leadingWhitespace = matches && matches[0];
894
+ }
895
+
896
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
897
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
898
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
899
+ }
900
+
901
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
902
+ /*
903
+ * Use the DOMParser API by default, fallback later if needs be
904
+ * DOMParser not work for svg when has multiple root element.
905
+ */
906
+
907
+ if (NAMESPACE === HTML_NAMESPACE) {
908
+ try {
909
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
910
+ } catch (_) {}
911
+ }
912
+ /* Use createHTMLDocument in case DOMParser is not available */
913
+
914
+
915
+ if (!doc || !doc.documentElement) {
916
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
917
+
918
+ try {
919
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
920
+ } catch (_) {// Syntax error if dirtyPayload is invalid xml
921
+ }
922
+ }
923
+
924
+ const body = doc.body || doc.documentElement;
925
+
926
+ if (dirty && leadingWhitespace) {
927
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
928
+ }
929
+ /* Work on whole document or just its body */
930
+
931
+
932
+ if (NAMESPACE === HTML_NAMESPACE) {
933
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
934
+ }
935
+
936
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
937
+ };
938
+ /**
939
+ * _createIterator
940
+ *
941
+ * @param {Document} root document/fragment to create iterator for
942
+ * @return {Iterator} iterator instance
943
+ */
944
+
945
+
946
+ const _createIterator = function _createIterator(root) {
947
+ return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise
948
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
949
+ };
950
+ /**
951
+ * _isClobbered
952
+ *
953
+ * @param {Node} elm element to check for clobbering attacks
954
+ * @return {Boolean} true if clobbered, false if safe
955
+ */
956
+
957
+
958
+ const _isClobbered = function _isClobbered(elm) {
959
+ 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' || typeof elm.hasChildNodes !== 'function');
960
+ };
961
+ /**
962
+ * _isNode
963
+ *
964
+ * @param {Node} obj object to check whether it's a DOM node
965
+ * @return {Boolean} true is object is a DOM node
966
+ */
967
+
968
+
969
+ const _isNode = function _isNode(object) {
970
+ return typeof Node === 'object' ? object instanceof Node : object && typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
971
+ };
972
+ /**
973
+ * _executeHook
974
+ * Execute user configurable hooks
975
+ *
976
+ * @param {String} entryPoint Name of the hook's entry point
977
+ * @param {Node} currentNode node to work on with the hook
978
+ * @param {Object} data additional hook parameters
979
+ */
980
+
981
+
982
+ const _executeHook = function _executeHook(entryPoint, currentNode, data) {
983
+ if (!hooks[entryPoint]) {
984
+ return;
985
+ }
986
+
987
+ arrayForEach(hooks[entryPoint], hook => {
988
+ hook.call(DOMPurify, currentNode, data, CONFIG);
989
+ });
990
+ };
991
+ /**
992
+ * _sanitizeElements
993
+ *
994
+ * @protect nodeName
995
+ * @protect textContent
996
+ * @protect removeChild
997
+ *
998
+ * @param {Node} currentNode to check for permission to exist
999
+ * @return {Boolean} true if node was killed, false if left alive
1000
+ */
1001
+
1002
+
1003
+ const _sanitizeElements = function _sanitizeElements(currentNode) {
1004
+ let content;
1005
+ /* Execute a hook if present */
1006
+
1007
+ _executeHook('beforeSanitizeElements', currentNode, null);
1008
+ /* Check if element is clobbered or can clobber */
1009
+
1010
+
1011
+ if (_isClobbered(currentNode)) {
1012
+ _forceRemove(currentNode);
1013
+
1014
+ return true;
1015
+ }
1016
+ /* Now let's check the element's type and name */
1017
+
1018
+
1019
+ const tagName = transformCaseFunc(currentNode.nodeName);
1020
+ /* Execute a hook if present */
1021
+
1022
+ _executeHook('uponSanitizeElement', currentNode, {
1023
+ tagName,
1024
+ allowedTags: ALLOWED_TAGS
1025
+ });
1026
+ /* Detect mXSS attempts abusing namespace confusion */
1027
+
1028
+
1029
+ if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
1030
+ _forceRemove(currentNode);
1031
+
1032
+ return true;
1033
+ }
1034
+ /* Remove element if anything forbids its presence */
1035
+
1036
+
1037
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1038
+ /* Check if we have a custom element to handle */
1039
+ if (!FORBID_TAGS[tagName] && _basicCustomElementTest(tagName)) {
1040
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
1041
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) return false;
1042
+ }
1043
+ /* Keep content except for bad-listed elements */
1044
+
1045
+
1046
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
1047
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
1048
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
1049
+
1050
+ if (childNodes && parentNode) {
1051
+ const childCount = childNodes.length;
1052
+
1053
+ for (let i = childCount - 1; i >= 0; --i) {
1054
+ parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
1055
+ }
1056
+ }
1057
+ }
1058
+
1059
+ _forceRemove(currentNode);
1060
+
1061
+ return true;
1062
+ }
1063
+ /* Check whether element has a valid namespace */
1064
+
1065
+
1066
+ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
1067
+ _forceRemove(currentNode);
1068
+
1069
+ return true;
1070
+ }
1071
+ /* Make sure that older browsers don't get noscript mXSS */
1072
+
1073
+
1074
+ if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
1075
+ _forceRemove(currentNode);
1076
+
1077
+ return true;
1078
+ }
1079
+ /* Sanitize element content to be template-safe */
1080
+
1081
+
1082
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
1083
+ /* Get the element's text content */
1084
+ content = currentNode.textContent;
1085
+ content = stringReplace(content, MUSTACHE_EXPR, ' ');
1086
+ content = stringReplace(content, ERB_EXPR, ' ');
1087
+ content = stringReplace(content, TMPLIT_EXPR, ' ');
1088
+
1089
+ if (currentNode.textContent !== content) {
1090
+ arrayPush(DOMPurify.removed, {
1091
+ element: currentNode.cloneNode()
1092
+ });
1093
+ currentNode.textContent = content;
1094
+ }
1095
+ }
1096
+ /* Execute a hook if present */
1097
+
1098
+
1099
+ _executeHook('afterSanitizeElements', currentNode, null);
1100
+
1101
+ return false;
1102
+ };
1103
+ /**
1104
+ * _isValidAttribute
1105
+ *
1106
+ * @param {string} lcTag Lowercase tag name of containing element.
1107
+ * @param {string} lcName Lowercase attribute name.
1108
+ * @param {string} value Attribute value.
1109
+ * @return {Boolean} Returns true if `value` is valid, otherwise false.
1110
+ */
1111
+ // eslint-disable-next-line complexity
1112
+
1113
+
1114
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1115
+ /* Make sure attribute cannot clobber */
1116
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1117
+ return false;
1118
+ }
1119
+ /* Allow valid data-* attributes: At least one character after "-"
1120
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
1121
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
1122
+ We don't need to check the value; it's always URI safe. */
1123
+
1124
+
1125
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
1126
+ if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND
1127
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1128
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
1129
+ _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
1130
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1131
+ 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 {
1132
+ return false;
1133
+ }
1134
+ /* Check value is safe. First, is attr inert? If so, is safe */
1135
+
1136
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; 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, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {
1137
+ return false;
1138
+ } else ;
1139
+
1140
+ return true;
1141
+ };
1142
+ /**
1143
+ * _basicCustomElementCheck
1144
+ * checks if at least one dash is included in tagName, and it's not the first char
1145
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
1146
+ * @param {string} tagName name of the tag of the node to sanitize
1147
+ */
1148
+
1149
+
1150
+ const _basicCustomElementTest = function _basicCustomElementTest(tagName) {
1151
+ return tagName.indexOf('-') > 0;
1152
+ };
1153
+ /**
1154
+ * _sanitizeAttributes
1155
+ *
1156
+ * @protect attributes
1157
+ * @protect nodeName
1158
+ * @protect removeAttribute
1159
+ * @protect setAttribute
1160
+ *
1161
+ * @param {Node} currentNode to sanitize
1162
+ */
1163
+
1164
+
1165
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
1166
+ let attr;
1167
+ let value;
1168
+ let lcName;
1169
+ let l;
1170
+ /* Execute a hook if present */
1171
+
1172
+ _executeHook('beforeSanitizeAttributes', currentNode, null);
1173
+
1174
+ const {
1175
+ attributes
1176
+ } = currentNode;
1177
+ /* Check if we have attributes; if not we might have a text node */
1178
+
1179
+ if (!attributes) {
1180
+ return;
1181
+ }
1182
+
1183
+ const hookEvent = {
1184
+ attrName: '',
1185
+ attrValue: '',
1186
+ keepAttr: true,
1187
+ allowedAttributes: ALLOWED_ATTR
1188
+ };
1189
+ l = attributes.length;
1190
+ /* Go backwards over all attributes; safely remove bad ones */
1191
+
1192
+ while (l--) {
1193
+ attr = attributes[l];
1194
+ const {
1195
+ name,
1196
+ namespaceURI
1197
+ } = attr;
1198
+ value = name === 'value' ? attr.value : stringTrim(attr.value);
1199
+ lcName = transformCaseFunc(name);
1200
+ /* Execute a hook if present */
1201
+
1202
+ hookEvent.attrName = lcName;
1203
+ hookEvent.attrValue = value;
1204
+ hookEvent.keepAttr = true;
1205
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1206
+
1207
+ _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
1208
+
1209
+ value = hookEvent.attrValue;
1210
+ /* Did the hooks approve of the attribute? */
1211
+
1212
+ if (hookEvent.forceKeepAttr) {
1213
+ continue;
1214
+ }
1215
+ /* Remove attribute */
1216
+
1217
+
1218
+ _removeAttribute(name, currentNode);
1219
+ /* Did the hooks approve of the attribute? */
1220
+
1221
+
1222
+ if (!hookEvent.keepAttr) {
1223
+ continue;
1224
+ }
1225
+ /* Work around a security issue in jQuery 3.0 */
1226
+
1227
+
1228
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
1229
+ _removeAttribute(name, currentNode);
1230
+
1231
+ continue;
1232
+ }
1233
+ /* Sanitize attribute content to be template-safe */
1234
+
1235
+
1236
+ if (SAFE_FOR_TEMPLATES) {
1237
+ value = stringReplace(value, MUSTACHE_EXPR, ' ');
1238
+ value = stringReplace(value, ERB_EXPR, ' ');
1239
+ value = stringReplace(value, TMPLIT_EXPR, ' ');
1240
+ }
1241
+ /* Is `value` valid for this attribute? */
1242
+
1243
+
1244
+ const lcTag = transformCaseFunc(currentNode.nodeName);
1245
+
1246
+ if (!_isValidAttribute(lcTag, lcName, value)) {
1247
+ continue;
1248
+ }
1249
+ /* Full DOM Clobbering protection via namespace isolation,
1250
+ * Prefix id and name attributes with `user-content-`
1251
+ */
1252
+
1253
+
1254
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
1255
+ // Remove the attribute with this value
1256
+ _removeAttribute(name, currentNode); // Prefix the value and later re-create the attribute with the sanitized value
1257
+
1258
+
1259
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
1260
+ }
1261
+ /* Handle attributes that require Trusted Types */
1262
+
1263
+
1264
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
1265
+ if (namespaceURI) ; else {
1266
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
1267
+ case 'TrustedHTML':
1268
+ {
1269
+ value = trustedTypesPolicy.createHTML(value);
1270
+ break;
1271
+ }
1272
+
1273
+ case 'TrustedScriptURL':
1274
+ {
1275
+ value = trustedTypesPolicy.createScriptURL(value);
1276
+ break;
1277
+ }
1278
+ }
1279
+ }
1280
+ }
1281
+ /* Handle invalid data-* attribute set by try-catching it */
1282
+
1283
+
1284
+ try {
1285
+ if (namespaceURI) {
1286
+ currentNode.setAttributeNS(namespaceURI, name, value);
1287
+ } else {
1288
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
1289
+ currentNode.setAttribute(name, value);
1290
+ }
1291
+
1292
+ arrayPop(DOMPurify.removed);
1293
+ } catch (_) {}
1294
+ }
1295
+ /* Execute a hook if present */
1296
+
1297
+
1298
+ _executeHook('afterSanitizeAttributes', currentNode, null);
1299
+ };
1300
+ /**
1301
+ * _sanitizeShadowDOM
1302
+ *
1303
+ * @param {DocumentFragment} fragment to iterate over recursively
1304
+ */
1305
+
1306
+
1307
+ const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
1308
+ let shadowNode;
1309
+
1310
+ const shadowIterator = _createIterator(fragment);
1311
+ /* Execute a hook if present */
1312
+
1313
+
1314
+ _executeHook('beforeSanitizeShadowDOM', fragment, null);
1315
+
1316
+ while (shadowNode = shadowIterator.nextNode()) {
1317
+ /* Execute a hook if present */
1318
+ _executeHook('uponSanitizeShadowNode', shadowNode, null);
1319
+ /* Sanitize tags and elements */
1320
+
1321
+
1322
+ if (_sanitizeElements(shadowNode)) {
1323
+ continue;
1324
+ }
1325
+ /* Deep shadow DOM detected */
1326
+
1327
+
1328
+ if (shadowNode.content instanceof DocumentFragment) {
1329
+ _sanitizeShadowDOM(shadowNode.content);
1330
+ }
1331
+ /* Check attributes, sanitize if necessary */
1332
+
1333
+
1334
+ _sanitizeAttributes(shadowNode);
1335
+ }
1336
+ /* Execute a hook if present */
1337
+
1338
+
1339
+ _executeHook('afterSanitizeShadowDOM', fragment, null);
1340
+ };
1341
+ /**
1342
+ * Sanitize
1343
+ * Public method providing core sanitation functionality
1344
+ *
1345
+ * @param {String|Node} dirty string or DOM node
1346
+ * @param {Object} configuration object
1347
+ */
1348
+ // eslint-disable-next-line complexity
1349
+
1350
+
1351
+ DOMPurify.sanitize = function (dirty) {
1352
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1353
+ let body;
1354
+ let importedNode;
1355
+ let currentNode;
1356
+ let returnNode;
1357
+ /* Make sure we have a string to sanitize.
1358
+ DO NOT return early, as this will return the wrong type if
1359
+ the user has requested a DOM object rather than a string */
1360
+
1361
+ IS_EMPTY_INPUT = !dirty;
1362
+
1363
+ if (IS_EMPTY_INPUT) {
1364
+ dirty = '<!-->';
1365
+ }
1366
+ /* Stringify, in case dirty is an object */
1367
+
1368
+
1369
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
1370
+ if (typeof dirty.toString === 'function') {
1371
+ dirty = dirty.toString();
1372
+
1373
+ if (typeof dirty !== 'string') {
1374
+ throw typeErrorCreate('dirty is not a string, aborting');
1375
+ }
1376
+ } else {
1377
+ throw typeErrorCreate('toString is not a function');
1378
+ }
1379
+ }
1380
+ /* Return dirty HTML if DOMPurify cannot run */
1381
+
1382
+
1383
+ if (!DOMPurify.isSupported) {
1384
+ return dirty;
1385
+ }
1386
+ /* Assign config vars */
1387
+
1388
+
1389
+ if (!SET_CONFIG) {
1390
+ _parseConfig(cfg);
1391
+ }
1392
+ /* Clean up removed elements */
1393
+
1394
+
1395
+ DOMPurify.removed = [];
1396
+ /* Check if dirty is correctly typed for IN_PLACE */
1397
+
1398
+ if (typeof dirty === 'string') {
1399
+ IN_PLACE = false;
1400
+ }
1401
+
1402
+ if (IN_PLACE) {
1403
+ /* Do some early pre-sanitization to avoid unsafe root nodes */
1404
+ if (dirty.nodeName) {
1405
+ const tagName = transformCaseFunc(dirty.nodeName);
1406
+
1407
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1408
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
1409
+ }
1410
+ }
1411
+ } else if (dirty instanceof Node) {
1412
+ /* If dirty is a DOM element, append to an empty document to avoid
1413
+ elements being stripped by the parser */
1414
+ body = _initDocument('<!---->');
1415
+ importedNode = body.ownerDocument.importNode(dirty, true);
1416
+
1417
+ if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
1418
+ /* Node is already a body, use as is */
1419
+ body = importedNode;
1420
+ } else if (importedNode.nodeName === 'HTML') {
1421
+ body = importedNode;
1422
+ } else {
1423
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1424
+ body.appendChild(importedNode);
1425
+ }
1426
+ } else {
1427
+ /* Exit directly if we have nothing to do */
1428
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
1429
+ dirty.indexOf('<') === -1) {
1430
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
1431
+ }
1432
+ /* Initialize the document to work on */
1433
+
1434
+
1435
+ body = _initDocument(dirty);
1436
+ /* Check we have a DOM node from the data */
1437
+
1438
+ if (!body) {
1439
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
1440
+ }
1441
+ }
1442
+ /* Remove first element node (ours) if FORCE_BODY is set */
1443
+
1444
+
1445
+ if (body && FORCE_BODY) {
1446
+ _forceRemove(body.firstChild);
1447
+ }
1448
+ /* Get node iterator */
1449
+
1450
+
1451
+ const nodeIterator = _createIterator(IN_PLACE ? dirty : body);
1452
+ /* Now start iterating over the created document */
1453
+
1454
+
1455
+ while (currentNode = nodeIterator.nextNode()) {
1456
+ /* Sanitize tags and elements */
1457
+ if (_sanitizeElements(currentNode)) {
1458
+ continue;
1459
+ }
1460
+ /* Shadow DOM detected, sanitize it */
1461
+
1462
+
1463
+ if (currentNode.content instanceof DocumentFragment) {
1464
+ _sanitizeShadowDOM(currentNode.content);
1465
+ }
1466
+ /* Check attributes, sanitize if necessary */
1467
+
1468
+
1469
+ _sanitizeAttributes(currentNode);
1470
+ }
1471
+ /* If we sanitized `dirty` in-place, return it. */
1472
+
1473
+
1474
+ if (IN_PLACE) {
1475
+ return dirty;
1476
+ }
1477
+ /* Return sanitized string or DOM */
1478
+
1479
+
1480
+ if (RETURN_DOM) {
1481
+ if (RETURN_DOM_FRAGMENT) {
1482
+ returnNode = createDocumentFragment.call(body.ownerDocument);
1483
+
1484
+ while (body.firstChild) {
1485
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1486
+ returnNode.appendChild(body.firstChild);
1487
+ }
1488
+ } else {
1489
+ returnNode = body;
1490
+ }
1491
+
1492
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmod) {
1493
+ /*
1494
+ AdoptNode() is not used because internal state is not reset
1495
+ (e.g. the past names map of a HTMLFormElement), this is safe
1496
+ in theory but we would rather not risk another attack vector.
1497
+ The state that is cloned by importNode() is explicitly defined
1498
+ by the specs.
1499
+ */
1500
+ returnNode = importNode.call(originalDocument, returnNode, true);
1501
+ }
1502
+
1503
+ return returnNode;
1504
+ }
1505
+
1506
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
1507
+ /* Serialize doctype if allowed */
1508
+
1509
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
1510
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
1511
+ }
1512
+ /* Sanitize final string template-safe */
1513
+
1514
+
1515
+ if (SAFE_FOR_TEMPLATES) {
1516
+ serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR, ' ');
1517
+ serializedHTML = stringReplace(serializedHTML, ERB_EXPR, ' ');
1518
+ serializedHTML = stringReplace(serializedHTML, TMPLIT_EXPR, ' ');
1519
+ }
1520
+
1521
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
1522
+ };
1523
+ /**
1524
+ * Public method to set the configuration once
1525
+ * setConfig
1526
+ *
1527
+ * @param {Object} cfg configuration object
1528
+ */
1529
+
1530
+
1531
+ DOMPurify.setConfig = function (cfg) {
1532
+ _parseConfig(cfg);
1533
+
1534
+ SET_CONFIG = true;
1535
+ };
1536
+ /**
1537
+ * Public method to remove the configuration
1538
+ * clearConfig
1539
+ *
1540
+ */
1541
+
1542
+
1543
+ DOMPurify.clearConfig = function () {
1544
+ CONFIG = null;
1545
+ SET_CONFIG = false;
1546
+ };
1547
+ /**
1548
+ * Public method to check if an attribute value is valid.
1549
+ * Uses last set config, if any. Otherwise, uses config defaults.
1550
+ * isValidAttribute
1551
+ *
1552
+ * @param {string} tag Tag name of containing element.
1553
+ * @param {string} attr Attribute name.
1554
+ * @param {string} value Attribute value.
1555
+ * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
1556
+ */
1557
+
1558
+
1559
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
1560
+ /* Initialize shared config vars if necessary. */
1561
+ if (!CONFIG) {
1562
+ _parseConfig({});
1563
+ }
1564
+
1565
+ const lcTag = transformCaseFunc(tag);
1566
+ const lcName = transformCaseFunc(attr);
1567
+ return _isValidAttribute(lcTag, lcName, value);
1568
+ };
1569
+ /**
1570
+ * AddHook
1571
+ * Public method to add DOMPurify hooks
1572
+ *
1573
+ * @param {String} entryPoint entry point for the hook to add
1574
+ * @param {Function} hookFunction function to execute
1575
+ */
1576
+
1577
+
1578
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
1579
+ if (typeof hookFunction !== 'function') {
1580
+ return;
1581
+ }
1582
+
1583
+ hooks[entryPoint] = hooks[entryPoint] || [];
1584
+ arrayPush(hooks[entryPoint], hookFunction);
1585
+ };
1586
+ /**
1587
+ * RemoveHook
1588
+ * Public method to remove a DOMPurify hook at a given entryPoint
1589
+ * (pops it from the stack of hooks if more are present)
1590
+ *
1591
+ * @param {String} entryPoint entry point for the hook to remove
1592
+ * @return {Function} removed(popped) hook
1593
+ */
1594
+
1595
+
1596
+ DOMPurify.removeHook = function (entryPoint) {
1597
+ if (hooks[entryPoint]) {
1598
+ return arrayPop(hooks[entryPoint]);
1599
+ }
1600
+ };
1601
+ /**
1602
+ * RemoveHooks
1603
+ * Public method to remove all DOMPurify hooks at a given entryPoint
1604
+ *
1605
+ * @param {String} entryPoint entry point for the hooks to remove
1606
+ */
1607
+
1608
+
1609
+ DOMPurify.removeHooks = function (entryPoint) {
1610
+ if (hooks[entryPoint]) {
1611
+ hooks[entryPoint] = [];
1612
+ }
1613
+ };
1614
+ /**
1615
+ * RemoveAllHooks
1616
+ * Public method to remove all DOMPurify hooks
1617
+ *
1618
+ */
1619
+
1620
+
1621
+ DOMPurify.removeAllHooks = function () {
1622
+ hooks = {};
1623
+ };
1624
+
1625
+ return DOMPurify;
1626
+ }
1627
+
1628
+ var purify = createDOMPurify();
1629
+
1630
+ return purify;
1631
+
1632
+ }));
1633
+ //# sourceMappingURL=purify.js.map