@touchvue/ui 1.0.0-beta.55 → 1.0.0-beta.56

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.
Files changed (676) hide show
  1. package/README.md +70 -70
  2. package/es/components/box/index.d.ts +1 -1
  3. package/es/components/breadcrumb/index.d.ts +1 -1
  4. package/es/components/button/index.d.ts +1 -1
  5. package/es/components/button/src/button.d.ts +1 -1
  6. package/es/components/calendar/index.d.ts +1 -1
  7. package/es/components/cascader/index.d.ts +1 -1
  8. package/es/components/center-scroll/index.d.ts +1 -1
  9. package/es/components/checkbox/index.d.ts +1 -1
  10. package/es/components/checkboxes/index.d.ts +1 -1
  11. package/es/components/collapse/index.d.ts +1 -1
  12. package/es/components/datepicker/index.d.ts +1 -1
  13. package/es/components/daterange/index.d.ts +1 -1
  14. package/es/components/dialog/index.d.ts +1 -1
  15. package/es/components/divider/index.d.ts +1 -1
  16. package/es/components/ellipsis/index.d.ts +1 -1
  17. package/es/components/export/index.d.ts +1 -1
  18. package/es/components/export/src/export.vue.d.ts +1 -1
  19. package/es/components/fix/index.d.ts +1 -1
  20. package/es/components/float/index.d.ts +1 -1
  21. package/es/components/form/index.d.ts +1 -1
  22. package/es/components/gap/index.d.ts +1 -1
  23. package/es/components/grid/index.d.ts +1 -1
  24. package/es/components/guider/index.d.ts +1 -1
  25. package/es/components/header/index.d.ts +1 -1
  26. package/es/components/icon/index.d.ts +1 -1
  27. package/es/components/import/index.d.ts +1 -1
  28. package/es/components/index.d.ts +1 -1
  29. package/es/components/input/index.d.ts +1 -1
  30. package/es/components/msg/index.d.ts +1 -1
  31. package/es/components/padding/index.d.ts +1 -1
  32. package/es/components/page/index.d.ts +1 -1
  33. package/es/components/param/index.d.ts +7 -7
  34. package/es/components/param/src/Param.vue.d.ts +3 -3
  35. package/es/components/pic/index.d.ts +10 -1
  36. package/es/components/pic/src/Pic.vue.d.ts +9 -0
  37. package/es/components/pic/src/pic.d.ts +7 -0
  38. package/es/components/progress/index.d.ts +1 -1
  39. package/es/components/range/index.d.ts +1 -1
  40. package/es/components/rate/index.d.ts +1 -1
  41. package/es/components/scroll/index.d.ts +17 -2
  42. package/es/components/scroll/src/Scroll.vue.d.ts +9 -0
  43. package/es/components/scroll/src/scroll.d.ts +7 -0
  44. package/es/components/segment/index.d.ts +1 -1
  45. package/es/components/select/index.d.ts +1 -1
  46. package/es/components/slide/index.d.ts +1 -1
  47. package/es/components/step/index.d.ts +1 -1
  48. package/es/components/switch/index.d.ts +1 -1
  49. package/es/components/tab/index.d.ts +1 -1
  50. package/es/components/table/index.d.ts +1 -1
  51. package/es/components/table/src/table-head.vue.d.ts +2 -0
  52. package/es/components/tag/index.d.ts +1 -1
  53. package/es/components/text/index.d.ts +1 -1
  54. package/es/components/timeline/src/timeline.vue.d.ts +4 -4
  55. package/es/components/tip/index.d.ts +1 -1
  56. package/es/components/tooltip/index.d.ts +1 -1
  57. package/es/components/transfer/index.d.ts +1 -1
  58. package/es/components/tree/index.d.ts +1 -1
  59. package/es/components/upload/index.d.ts +1 -1
  60. package/es/components/upload/src/upload.vue.d.ts +6 -4
  61. package/es/index.d.mjs.map +1 -1
  62. package/es/node_modules/.pnpm/dompurify@3.2.6/node_modules/dompurify/dist/purify.es.mjs +1346 -0
  63. package/es/node_modules/.pnpm/dompurify@3.2.6/node_modules/dompurify/dist/purify.es.mjs.map +1 -0
  64. package/es/packages/components/box/index.mjs.map +1 -1
  65. package/es/packages/components/box/src/box.mjs.map +1 -1
  66. package/es/packages/components/box/src/box.vue2.mjs +1 -1
  67. package/es/packages/components/box/src/box.vue2.mjs.map +1 -1
  68. package/es/packages/components/breadcrumb/index.mjs.map +1 -1
  69. package/es/packages/components/breadcrumb/src/breadcrumb-item.mjs.map +1 -1
  70. package/es/packages/components/breadcrumb/src/breadcrumb-item.vue.mjs.map +1 -1
  71. package/es/packages/components/breadcrumb/src/breadcrumb-item.vue2.mjs.map +1 -1
  72. package/es/packages/components/breadcrumb/src/breadcrumb.mjs.map +1 -1
  73. package/es/packages/components/breadcrumb/src/breadcrumb.vue.mjs.map +1 -1
  74. package/es/packages/components/breadcrumb/src/breadcrumb.vue2.mjs.map +1 -1
  75. package/es/packages/components/button/index.d.mjs.map +1 -1
  76. package/es/packages/components/button/index.mjs.map +1 -1
  77. package/es/packages/components/button/src/button.mjs.map +1 -1
  78. package/es/packages/components/button/src/button.vue2.mjs +9 -9
  79. package/es/packages/components/button/src/button.vue2.mjs.map +1 -1
  80. package/es/packages/components/calendar/index.mjs.map +1 -1
  81. package/es/packages/components/calendar/src/calendar.mjs.map +1 -1
  82. package/es/packages/components/calendar/src/calendar.vue2.mjs +23 -1
  83. package/es/packages/components/calendar/src/calendar.vue2.mjs.map +1 -1
  84. package/es/packages/components/cascader/index.mjs.map +1 -1
  85. package/es/packages/components/cascader/src/cascader-item.vue2.mjs +2 -1
  86. package/es/packages/components/cascader/src/cascader-item.vue2.mjs.map +1 -1
  87. package/es/packages/components/cascader/src/cascader.vue2.mjs +4 -3
  88. package/es/packages/components/cascader/src/cascader.vue2.mjs.map +1 -1
  89. package/es/packages/components/center-scroll/index.d.mjs.map +1 -1
  90. package/es/packages/components/center-scroll/index.mjs.map +1 -1
  91. package/es/packages/components/center-scroll/src/CenterScroll.vue2.mjs.map +1 -1
  92. package/es/packages/components/center-scroll/src/center-scroll.mjs.map +1 -1
  93. package/es/packages/components/checkbox/index.mjs.map +1 -1
  94. package/es/packages/components/checkbox/src/Checkbox.vue2.mjs +2 -2
  95. package/es/packages/components/checkbox/src/Checkbox.vue2.mjs.map +1 -1
  96. package/es/packages/components/checkboxes/index.mjs.map +1 -1
  97. package/es/packages/components/checkboxes/src/Checkboxes.vue2.mjs +2 -2
  98. package/es/packages/components/checkboxes/src/Checkboxes.vue2.mjs.map +1 -1
  99. package/es/packages/components/collapse/index.mjs.map +1 -1
  100. package/es/packages/components/collapse/src/collapse-item.vue2.mjs +3 -3
  101. package/es/packages/components/collapse/src/collapse-item.vue2.mjs.map +1 -1
  102. package/es/packages/components/collapse/src/collapse.vue2.mjs +1 -1
  103. package/es/packages/components/collapse/src/collapse.vue2.mjs.map +1 -1
  104. package/es/packages/components/datepicker/index.mjs.map +1 -1
  105. package/es/packages/components/datepicker/src/DatePicker.vue2.mjs.map +1 -1
  106. package/es/packages/components/datepicker/src/Picker.vue2.mjs.map +1 -1
  107. package/es/packages/components/datepicker/src/date-picker.mjs.map +1 -1
  108. package/es/packages/components/datepicker/src/use-date-picker.mjs.map +1 -1
  109. package/es/packages/components/daterange/index.mjs.map +1 -1
  110. package/es/packages/components/daterange/src/date-range.vue2.mjs +12 -12
  111. package/es/packages/components/daterange/src/date-range.vue2.mjs.map +1 -1
  112. package/es/packages/components/dialog/index.d.mjs.map +1 -1
  113. package/es/packages/components/dialog/index.mjs.map +1 -1
  114. package/es/packages/components/dialog/src/Dialog.vue2.mjs.map +1 -1
  115. package/es/packages/components/dialog/src/dialog.mjs.map +1 -1
  116. package/es/packages/components/divider/index.mjs.map +1 -1
  117. package/es/packages/components/divider/src/divider.vue2.mjs +1 -1
  118. package/es/packages/components/divider/src/divider.vue2.mjs.map +1 -1
  119. package/es/packages/components/ellipsis/index.d.mjs.map +1 -1
  120. package/es/packages/components/ellipsis/index.mjs.map +1 -1
  121. package/es/packages/components/ellipsis/src/Ellipsis.vue2.mjs.map +1 -1
  122. package/es/packages/components/ellipsis/src/ellipsis.mjs.map +1 -1
  123. package/es/packages/components/export/index.mjs.map +1 -1
  124. package/es/packages/components/export/src/export.vue2.mjs +1 -1
  125. package/es/packages/components/export/src/export.vue2.mjs.map +1 -1
  126. package/es/packages/components/fix/index.d.mjs.map +1 -1
  127. package/es/packages/components/fix/index.mjs.map +1 -1
  128. package/es/packages/components/fix/src/Fix.vue2.mjs.map +1 -1
  129. package/es/packages/components/fix/src/fix.mjs.map +1 -1
  130. package/es/packages/components/float/index.d.mjs.map +1 -1
  131. package/es/packages/components/float/index.mjs.map +1 -1
  132. package/es/packages/components/float/src/Float.vue2.mjs.map +1 -1
  133. package/es/packages/components/float/src/float.mjs.map +1 -1
  134. package/es/packages/components/form/index.mjs.map +1 -1
  135. package/es/packages/components/form/src/form-item.vue2.mjs.map +1 -1
  136. package/es/packages/components/form/src/form.vue2.mjs.map +1 -1
  137. package/es/packages/components/gap/index.mjs.map +1 -1
  138. package/es/packages/components/gap/src/gap.vue2.mjs.map +1 -1
  139. package/es/packages/components/grid/index.d.mjs.map +1 -1
  140. package/es/packages/components/grid/index.mjs.map +1 -1
  141. package/es/packages/components/grid/src/grid-item.vue2.mjs +1 -1
  142. package/es/packages/components/grid/src/grid-item.vue2.mjs.map +1 -1
  143. package/es/packages/components/grid/src/grid.vue2.mjs +1 -1
  144. package/es/packages/components/grid/src/grid.vue2.mjs.map +1 -1
  145. package/es/packages/components/guider/index.d.mjs.map +1 -1
  146. package/es/packages/components/guider/index.mjs.map +1 -1
  147. package/es/packages/components/guider/src/guider.vue2.mjs +1 -1
  148. package/es/packages/components/guider/src/guider.vue2.mjs.map +1 -1
  149. package/es/packages/components/header/index.mjs.map +1 -1
  150. package/es/packages/components/header/src/header.vue2.mjs +4 -4
  151. package/es/packages/components/header/src/header.vue2.mjs.map +1 -1
  152. package/es/packages/components/icon/index.d.mjs.map +1 -1
  153. package/es/packages/components/icon/index.mjs.map +1 -1
  154. package/es/packages/components/icon/src/icon.vue2.mjs +1 -1
  155. package/es/packages/components/icon/src/icon.vue2.mjs.map +1 -1
  156. package/es/packages/components/import/index.mjs.map +1 -1
  157. package/es/packages/components/import/src/import.vue2.mjs +2 -2
  158. package/es/packages/components/import/src/import.vue2.mjs.map +1 -1
  159. package/es/packages/components/input/index.mjs.map +1 -1
  160. package/es/packages/components/input/src/input.vue2.mjs +2 -2
  161. package/es/packages/components/input/src/input.vue2.mjs.map +1 -1
  162. package/es/packages/components/msg/index.d.mjs.map +1 -1
  163. package/es/packages/components/msg/index.mjs.map +1 -1
  164. package/es/packages/components/msg/src/msg.vue2.mjs +15 -15
  165. package/es/packages/components/msg/src/msg.vue2.mjs.map +1 -1
  166. package/es/packages/components/padding/index.mjs.map +1 -1
  167. package/es/packages/components/padding/src/padding.vue2.mjs +1 -1
  168. package/es/packages/components/padding/src/padding.vue2.mjs.map +1 -1
  169. package/es/packages/components/page/index.mjs.map +1 -1
  170. package/es/packages/components/page/src/page.vue2.mjs.map +1 -1
  171. package/es/packages/components/param/index.d.mjs.map +1 -1
  172. package/es/packages/components/param/index.mjs.map +1 -1
  173. package/es/packages/components/param/src/Param.vue2.mjs.map +1 -1
  174. package/es/packages/components/param/src/ParamItem.vue.mjs.map +1 -1
  175. package/es/packages/components/param/src/param-item.mjs.map +1 -1
  176. package/es/packages/components/param/src/param.mjs.map +1 -1
  177. package/es/packages/components/pic/index.d.mjs.map +1 -1
  178. package/es/packages/components/pic/index.mjs.map +1 -1
  179. package/es/packages/components/pic/src/Pic.vue2.mjs +18 -2
  180. package/es/packages/components/pic/src/Pic.vue2.mjs.map +1 -1
  181. package/es/packages/components/pic/src/PicViewer.vue2.mjs +1 -1
  182. package/es/packages/components/pic/src/PicViewer.vue2.mjs.map +1 -1
  183. package/es/packages/components/pic/src/pic.mjs +7 -0
  184. package/es/packages/components/pic/src/pic.mjs.map +1 -1
  185. package/es/packages/components/progress/index.d.mjs.map +1 -1
  186. package/es/packages/components/progress/index.mjs.map +1 -1
  187. package/es/packages/components/progress/src/Progress.vue.mjs.map +1 -1
  188. package/es/packages/components/progress/src/Progress.vue2.mjs.map +1 -1
  189. package/es/packages/components/progress/src/progress.mjs.map +1 -1
  190. package/es/packages/components/range/index.mjs.map +1 -1
  191. package/es/packages/components/range/src/range.vue2.mjs +4 -4
  192. package/es/packages/components/range/src/range.vue2.mjs.map +1 -1
  193. package/es/packages/components/rate/index.mjs.map +1 -1
  194. package/es/packages/components/rate/src/rate.vue2.mjs.map +1 -1
  195. package/es/packages/components/scroll/index.d.mjs.map +1 -1
  196. package/es/packages/components/scroll/index.mjs.map +1 -1
  197. package/es/packages/components/scroll/src/Scroll.vue2.mjs +3 -0
  198. package/es/packages/components/scroll/src/Scroll.vue2.mjs.map +1 -1
  199. package/es/packages/components/scroll/src/ScrollPoint.vue2.mjs.map +1 -1
  200. package/es/packages/components/scroll/src/scroll-point.mjs.map +1 -1
  201. package/es/packages/components/scroll/src/scroll.mjs +7 -0
  202. package/es/packages/components/scroll/src/scroll.mjs.map +1 -1
  203. package/es/packages/components/segment/index.mjs.map +1 -1
  204. package/es/packages/components/segment/src/segment.vue.mjs +12 -14
  205. package/es/packages/components/segment/src/segment.vue.mjs.map +1 -1
  206. package/es/packages/components/select/index.mjs.map +1 -1
  207. package/es/packages/components/select/src/hooks/use-select-class-style.mjs.map +1 -1
  208. package/es/packages/components/select/src/hooks/use-select-option-data.mjs.map +1 -1
  209. package/es/packages/components/select/src/select.vue2.mjs +1 -0
  210. package/es/packages/components/select/src/select.vue2.mjs.map +1 -1
  211. package/es/packages/components/slide/index.mjs.map +1 -1
  212. package/es/packages/components/slide/src/slide.vue2.mjs +1 -1
  213. package/es/packages/components/slide/src/slide.vue2.mjs.map +1 -1
  214. package/es/packages/components/step/index.mjs.map +1 -1
  215. package/es/packages/components/step/src/step.vue2.mjs.map +1 -1
  216. package/es/packages/components/switch/index.mjs.map +1 -1
  217. package/es/packages/components/switch/src/switch.vue2.mjs.map +1 -1
  218. package/es/packages/components/tab/index.mjs.map +1 -1
  219. package/es/packages/components/tab/src/tab-item.vue2.mjs +1 -1
  220. package/es/packages/components/tab/src/tab-item.vue2.mjs.map +1 -1
  221. package/es/packages/components/tab/src/tab.vue2.mjs +7 -7
  222. package/es/packages/components/tab/src/tab.vue2.mjs.map +1 -1
  223. package/es/packages/components/table/index.mjs.map +1 -1
  224. package/es/packages/components/table/src/table-body.vue2.mjs.map +1 -1
  225. package/es/packages/components/table/src/table-config.vue2.mjs.map +1 -1
  226. package/es/packages/components/table/src/table-head.vue2.mjs +101 -45
  227. package/es/packages/components/table/src/table-head.vue2.mjs.map +1 -1
  228. package/es/packages/components/table/src/table.vue2.mjs +198 -74
  229. package/es/packages/components/table/src/table.vue2.mjs.map +1 -1
  230. package/es/packages/components/tag/index.d.mjs.map +1 -1
  231. package/es/packages/components/tag/index.mjs.map +1 -1
  232. package/es/packages/components/tag/src/tag.vue2.mjs +4 -4
  233. package/es/packages/components/tag/src/tag.vue2.mjs.map +1 -1
  234. package/es/packages/components/text/index.mjs.map +1 -1
  235. package/es/packages/components/text/src/text.vue2.mjs +4 -4
  236. package/es/packages/components/text/src/text.vue2.mjs.map +1 -1
  237. package/es/packages/components/timeline/index.d.mjs.map +1 -1
  238. package/es/packages/components/timeline/index.mjs.map +1 -1
  239. package/es/packages/components/timeline/src/timeline.vue.mjs.map +1 -1
  240. package/es/packages/components/timeline/src/timeline.vue2.mjs.map +1 -1
  241. package/es/packages/components/tip/index.d.mjs.map +1 -1
  242. package/es/packages/components/tip/index.mjs.map +1 -1
  243. package/es/packages/components/tip/src/tip.mjs.map +1 -1
  244. package/es/packages/components/tip/src/tip.vue2.mjs.map +1 -1
  245. package/es/packages/components/tooltip/index.mjs.map +1 -1
  246. package/es/packages/components/tooltip/src/tooltip.mjs.map +1 -1
  247. package/es/packages/components/tooltip/src/tooltip.vue2.mjs.map +1 -1
  248. package/es/packages/components/transfer/index.mjs.map +1 -1
  249. package/es/packages/components/transfer/src/transfer.vue2.mjs +9 -9
  250. package/es/packages/components/transfer/src/transfer.vue2.mjs.map +1 -1
  251. package/es/packages/components/tree/index.mjs.map +1 -1
  252. package/es/packages/components/tree/src/tree-item.vue2.mjs +27 -26
  253. package/es/packages/components/tree/src/tree-item.vue2.mjs.map +1 -1
  254. package/es/packages/components/tree/src/tree.vue2.mjs +4 -4
  255. package/es/packages/components/tree/src/tree.vue2.mjs.map +1 -1
  256. package/es/packages/components/upload/index.mjs.map +1 -1
  257. package/es/packages/components/upload/src/upload.vue2.mjs +210 -160
  258. package/es/packages/components/upload/src/upload.vue2.mjs.map +1 -1
  259. package/es/packages/directives/align/index.d.mjs.map +1 -1
  260. package/es/packages/directives/align/index.mjs.map +1 -1
  261. package/es/packages/directives/align/src/align.d.mjs.map +1 -1
  262. package/es/packages/directives/align/src/align.mjs.map +1 -1
  263. package/es/packages/directives/color/index.d.mjs.map +1 -1
  264. package/es/packages/directives/color/index.mjs.map +1 -1
  265. package/es/packages/directives/color/src/color.d.mjs.map +1 -1
  266. package/es/packages/directives/color/src/color.mjs.map +1 -1
  267. package/es/packages/directives/dis/index.d.mjs.map +1 -1
  268. package/es/packages/directives/dis/index.mjs.map +1 -1
  269. package/es/packages/directives/dis/src/dis.d.mjs.map +1 -1
  270. package/es/packages/directives/dis/src/dis.mjs.map +1 -1
  271. package/es/packages/directives/hide/src/hide.mjs.map +1 -1
  272. package/es/packages/directives/index.d.mjs.map +1 -1
  273. package/es/packages/directives/index.mjs.map +1 -1
  274. package/es/packages/directives/loading/index.d.mjs.map +1 -1
  275. package/es/packages/directives/loading/index.mjs.map +1 -1
  276. package/es/packages/directives/loading/src/loading.d.mjs.map +1 -1
  277. package/es/packages/directives/loading/src/loading.mjs.map +1 -1
  278. package/es/packages/directives/press/src/press.mjs.map +1 -1
  279. package/es/packages/directives/size/index.d.mjs.map +1 -1
  280. package/es/packages/directives/size/index.mjs.map +1 -1
  281. package/es/packages/directives/size/src/size.d.mjs.map +1 -1
  282. package/es/packages/directives/size/src/size.mjs.map +1 -1
  283. package/es/packages/directives/tip/index.d.mjs.map +1 -1
  284. package/es/packages/directives/tip/index.mjs.map +1 -1
  285. package/es/packages/directives/tip/src/tip.d.mjs.map +1 -1
  286. package/es/packages/hooks/useDevice.mjs.map +1 -1
  287. package/es/packages/hooks/useFormItem.mjs.map +1 -1
  288. package/es/packages/hooks/useSetClass.mjs.map +1 -1
  289. package/es/packages/hooks/useWidthStyle.mjs.map +1 -1
  290. package/es/packages/locale/format.mjs.map +1 -1
  291. package/es/packages/locale/index.d.mjs.map +1 -1
  292. package/es/packages/locale/index.mjs.map +1 -1
  293. package/es/packages/locale/lang/en-US.mjs.map +1 -1
  294. package/es/packages/locale/lang/zh-CN.mjs.map +1 -1
  295. package/es/packages/resolver/resolver.mjs.map +1 -1
  296. package/es/packages/utils/ajax.mjs.map +1 -1
  297. package/es/packages/utils/beforeChange.mjs.map +1 -1
  298. package/es/packages/utils/compare.d.mjs.map +1 -1
  299. package/es/packages/utils/compare.mjs.map +1 -1
  300. package/es/packages/utils/config.mjs.map +1 -1
  301. package/es/packages/utils/date.mjs.map +1 -1
  302. package/es/packages/utils/disabledArea.d.mjs.map +1 -1
  303. package/es/packages/utils/disabledArea.mjs.map +1 -1
  304. package/es/packages/utils/dom.mjs.map +1 -1
  305. package/es/packages/utils/fileAjax.mjs.map +1 -1
  306. package/es/packages/utils/isModified.d.mjs.map +1 -1
  307. package/es/packages/utils/isModified.mjs.map +1 -1
  308. package/es/packages/utils/jsencrypt/JSEncrypt.mjs.map +1 -1
  309. package/es/packages/utils/jsencrypt/JSEncryptRSAKey.mjs.map +1 -1
  310. package/es/packages/utils/jsencrypt/jselib/asn1js/asn1.mjs.map +1 -1
  311. package/es/packages/utils/jsencrypt/jselib/asn1js/base64.mjs.map +1 -1
  312. package/es/packages/utils/jsencrypt/jselib/asn1js/hex.mjs.map +1 -1
  313. package/es/packages/utils/jsencrypt/jselib/asn1js/int10.mjs.map +1 -1
  314. package/es/packages/utils/jsencrypt/jselib/asn1js/oids.mjs.map +1 -1
  315. package/es/packages/utils/jsencrypt/jselib/jsbn/base64.mjs.map +1 -1
  316. package/es/packages/utils/jsencrypt/jselib/jsbn/jsbn.mjs.map +1 -1
  317. package/es/packages/utils/jsencrypt/jselib/jsbn/prng4.mjs.map +1 -1
  318. package/es/packages/utils/jsencrypt/jselib/jsbn/rng.mjs.map +1 -1
  319. package/es/packages/utils/jsencrypt/jselib/jsbn/rsa.mjs.map +1 -1
  320. package/es/packages/utils/jsencrypt/jselib/jsbn/util.mjs.map +1 -1
  321. package/es/packages/utils/jsencrypt/jselib/jsrsasign/asn1-1.0.mjs.map +1 -1
  322. package/es/packages/utils/jsencrypt/jselib/jsrsasign/yahoo.mjs.map +1 -1
  323. package/es/packages/utils/jsencrypt/util.mjs.map +1 -1
  324. package/es/packages/utils/md5.mjs.map +1 -1
  325. package/es/packages/utils/print.mjs +1 -1
  326. package/es/packages/utils/print.mjs.map +1 -1
  327. package/es/packages/utils/ratio.mjs.map +1 -1
  328. package/es/packages/utils/sign.mjs.map +1 -1
  329. package/es/packages/utils/theme.mjs.map +1 -1
  330. package/es/packages/utils/types.mjs.map +1 -1
  331. package/es/packages/utils/util.mjs.map +1 -1
  332. package/es/packages/utils/uuid.mjs.map +1 -1
  333. package/es/packages/utils/validate.mjs.map +1 -1
  334. package/es/ui/index.d.ts +5 -5
  335. package/lib/components/box/index.d.ts +1 -1
  336. package/lib/components/breadcrumb/index.d.ts +1 -1
  337. package/lib/components/button/index.d.ts +1 -1
  338. package/lib/components/button/src/button.d.ts +1 -1
  339. package/lib/components/calendar/index.d.ts +1 -1
  340. package/lib/components/cascader/index.d.ts +1 -1
  341. package/lib/components/center-scroll/index.d.ts +1 -1
  342. package/lib/components/checkbox/index.d.ts +1 -1
  343. package/lib/components/checkboxes/index.d.ts +1 -1
  344. package/lib/components/collapse/index.d.ts +1 -1
  345. package/lib/components/datepicker/index.d.ts +1 -1
  346. package/lib/components/daterange/index.d.ts +1 -1
  347. package/lib/components/dialog/index.d.ts +1 -1
  348. package/lib/components/divider/index.d.ts +1 -1
  349. package/lib/components/ellipsis/index.d.ts +1 -1
  350. package/lib/components/export/index.d.ts +1 -1
  351. package/lib/components/export/src/export.vue.d.ts +1 -1
  352. package/lib/components/fix/index.d.ts +1 -1
  353. package/lib/components/float/index.d.ts +1 -1
  354. package/lib/components/form/index.d.ts +1 -1
  355. package/lib/components/gap/index.d.ts +1 -1
  356. package/lib/components/grid/index.d.ts +1 -1
  357. package/lib/components/guider/index.d.ts +1 -1
  358. package/lib/components/header/index.d.ts +1 -1
  359. package/lib/components/icon/index.d.ts +1 -1
  360. package/lib/components/import/index.d.ts +1 -1
  361. package/lib/components/index.d.ts +1 -1
  362. package/lib/components/input/index.d.ts +1 -1
  363. package/lib/components/msg/index.d.ts +1 -1
  364. package/lib/components/padding/index.d.ts +1 -1
  365. package/lib/components/page/index.d.ts +1 -1
  366. package/lib/components/param/index.d.ts +7 -7
  367. package/lib/components/param/src/Param.vue.d.ts +3 -3
  368. package/lib/components/pic/index.d.ts +10 -1
  369. package/lib/components/pic/src/Pic.vue.d.ts +9 -0
  370. package/lib/components/pic/src/pic.d.ts +7 -0
  371. package/lib/components/progress/index.d.ts +1 -1
  372. package/lib/components/range/index.d.ts +1 -1
  373. package/lib/components/rate/index.d.ts +1 -1
  374. package/lib/components/scroll/index.d.ts +17 -2
  375. package/lib/components/scroll/src/Scroll.vue.d.ts +9 -0
  376. package/lib/components/scroll/src/scroll.d.ts +7 -0
  377. package/lib/components/segment/index.d.ts +1 -1
  378. package/lib/components/select/index.d.ts +1 -1
  379. package/lib/components/slide/index.d.ts +1 -1
  380. package/lib/components/step/index.d.ts +1 -1
  381. package/lib/components/switch/index.d.ts +1 -1
  382. package/lib/components/tab/index.d.ts +1 -1
  383. package/lib/components/table/index.d.ts +1 -1
  384. package/lib/components/table/src/table-head.vue.d.ts +2 -0
  385. package/lib/components/tag/index.d.ts +1 -1
  386. package/lib/components/text/index.d.ts +1 -1
  387. package/lib/components/timeline/src/timeline.vue.d.ts +4 -4
  388. package/lib/components/tip/index.d.ts +1 -1
  389. package/lib/components/tooltip/index.d.ts +1 -1
  390. package/lib/components/transfer/index.d.ts +1 -1
  391. package/lib/components/tree/index.d.ts +1 -1
  392. package/lib/components/upload/index.d.ts +1 -1
  393. package/lib/components/upload/src/upload.vue.d.ts +6 -4
  394. package/lib/index.d.js.map +1 -1
  395. package/lib/node_modules/.pnpm/dompurify@3.2.6/node_modules/dompurify/dist/purify.es.js +1350 -0
  396. package/lib/node_modules/.pnpm/dompurify@3.2.6/node_modules/dompurify/dist/purify.es.js.map +1 -0
  397. package/lib/packages/components/box/index.js.map +1 -1
  398. package/lib/packages/components/box/src/box.js.map +1 -1
  399. package/lib/packages/components/box/src/box.vue2.js +1 -1
  400. package/lib/packages/components/box/src/box.vue2.js.map +1 -1
  401. package/lib/packages/components/breadcrumb/index.js.map +1 -1
  402. package/lib/packages/components/breadcrumb/src/breadcrumb-item.js.map +1 -1
  403. package/lib/packages/components/breadcrumb/src/breadcrumb-item.vue.js.map +1 -1
  404. package/lib/packages/components/breadcrumb/src/breadcrumb-item.vue2.js.map +1 -1
  405. package/lib/packages/components/breadcrumb/src/breadcrumb.js.map +1 -1
  406. package/lib/packages/components/breadcrumb/src/breadcrumb.vue.js.map +1 -1
  407. package/lib/packages/components/breadcrumb/src/breadcrumb.vue2.js.map +1 -1
  408. package/lib/packages/components/button/index.d.js.map +1 -1
  409. package/lib/packages/components/button/index.js.map +1 -1
  410. package/lib/packages/components/button/src/button.js.map +1 -1
  411. package/lib/packages/components/button/src/button.vue2.js +9 -9
  412. package/lib/packages/components/button/src/button.vue2.js.map +1 -1
  413. package/lib/packages/components/calendar/index.js.map +1 -1
  414. package/lib/packages/components/calendar/src/calendar.js.map +1 -1
  415. package/lib/packages/components/calendar/src/calendar.vue2.js +23 -1
  416. package/lib/packages/components/calendar/src/calendar.vue2.js.map +1 -1
  417. package/lib/packages/components/cascader/index.js.map +1 -1
  418. package/lib/packages/components/cascader/src/cascader-item.vue2.js +2 -1
  419. package/lib/packages/components/cascader/src/cascader-item.vue2.js.map +1 -1
  420. package/lib/packages/components/cascader/src/cascader.vue2.js +4 -3
  421. package/lib/packages/components/cascader/src/cascader.vue2.js.map +1 -1
  422. package/lib/packages/components/center-scroll/index.d.js.map +1 -1
  423. package/lib/packages/components/center-scroll/index.js.map +1 -1
  424. package/lib/packages/components/center-scroll/src/CenterScroll.vue2.js.map +1 -1
  425. package/lib/packages/components/center-scroll/src/center-scroll.js.map +1 -1
  426. package/lib/packages/components/checkbox/index.js.map +1 -1
  427. package/lib/packages/components/checkbox/src/Checkbox.vue2.js +2 -2
  428. package/lib/packages/components/checkbox/src/Checkbox.vue2.js.map +1 -1
  429. package/lib/packages/components/checkboxes/index.js.map +1 -1
  430. package/lib/packages/components/checkboxes/src/Checkboxes.vue2.js +2 -2
  431. package/lib/packages/components/checkboxes/src/Checkboxes.vue2.js.map +1 -1
  432. package/lib/packages/components/collapse/index.js.map +1 -1
  433. package/lib/packages/components/collapse/src/collapse-item.vue2.js +3 -3
  434. package/lib/packages/components/collapse/src/collapse-item.vue2.js.map +1 -1
  435. package/lib/packages/components/collapse/src/collapse.vue2.js +1 -1
  436. package/lib/packages/components/collapse/src/collapse.vue2.js.map +1 -1
  437. package/lib/packages/components/datepicker/index.js.map +1 -1
  438. package/lib/packages/components/datepicker/src/DatePicker.vue2.js.map +1 -1
  439. package/lib/packages/components/datepicker/src/Picker.vue2.js.map +1 -1
  440. package/lib/packages/components/datepicker/src/date-picker.js.map +1 -1
  441. package/lib/packages/components/datepicker/src/use-date-picker.js.map +1 -1
  442. package/lib/packages/components/daterange/index.js.map +1 -1
  443. package/lib/packages/components/daterange/src/date-range.vue2.js +12 -12
  444. package/lib/packages/components/daterange/src/date-range.vue2.js.map +1 -1
  445. package/lib/packages/components/dialog/index.d.js.map +1 -1
  446. package/lib/packages/components/dialog/index.js.map +1 -1
  447. package/lib/packages/components/dialog/src/Dialog.vue2.js.map +1 -1
  448. package/lib/packages/components/dialog/src/dialog.js.map +1 -1
  449. package/lib/packages/components/divider/index.js.map +1 -1
  450. package/lib/packages/components/divider/src/divider.vue2.js +1 -1
  451. package/lib/packages/components/divider/src/divider.vue2.js.map +1 -1
  452. package/lib/packages/components/ellipsis/index.d.js.map +1 -1
  453. package/lib/packages/components/ellipsis/index.js.map +1 -1
  454. package/lib/packages/components/ellipsis/src/Ellipsis.vue2.js.map +1 -1
  455. package/lib/packages/components/ellipsis/src/ellipsis.js.map +1 -1
  456. package/lib/packages/components/export/index.js.map +1 -1
  457. package/lib/packages/components/export/src/export.vue2.js +1 -1
  458. package/lib/packages/components/export/src/export.vue2.js.map +1 -1
  459. package/lib/packages/components/fix/index.d.js.map +1 -1
  460. package/lib/packages/components/fix/index.js.map +1 -1
  461. package/lib/packages/components/fix/src/Fix.vue2.js.map +1 -1
  462. package/lib/packages/components/fix/src/fix.js.map +1 -1
  463. package/lib/packages/components/float/index.d.js.map +1 -1
  464. package/lib/packages/components/float/index.js.map +1 -1
  465. package/lib/packages/components/float/src/Float.vue2.js.map +1 -1
  466. package/lib/packages/components/float/src/float.js.map +1 -1
  467. package/lib/packages/components/form/index.js.map +1 -1
  468. package/lib/packages/components/form/src/form-item.vue2.js.map +1 -1
  469. package/lib/packages/components/form/src/form.vue2.js.map +1 -1
  470. package/lib/packages/components/gap/index.js.map +1 -1
  471. package/lib/packages/components/gap/src/gap.vue2.js.map +1 -1
  472. package/lib/packages/components/grid/index.d.js.map +1 -1
  473. package/lib/packages/components/grid/index.js.map +1 -1
  474. package/lib/packages/components/grid/src/grid-item.vue2.js +1 -1
  475. package/lib/packages/components/grid/src/grid-item.vue2.js.map +1 -1
  476. package/lib/packages/components/grid/src/grid.vue2.js +1 -1
  477. package/lib/packages/components/grid/src/grid.vue2.js.map +1 -1
  478. package/lib/packages/components/guider/index.d.js.map +1 -1
  479. package/lib/packages/components/guider/index.js.map +1 -1
  480. package/lib/packages/components/guider/src/guider.vue2.js +1 -1
  481. package/lib/packages/components/guider/src/guider.vue2.js.map +1 -1
  482. package/lib/packages/components/header/index.js.map +1 -1
  483. package/lib/packages/components/header/src/header.vue2.js +4 -4
  484. package/lib/packages/components/header/src/header.vue2.js.map +1 -1
  485. package/lib/packages/components/icon/index.d.js.map +1 -1
  486. package/lib/packages/components/icon/index.js.map +1 -1
  487. package/lib/packages/components/icon/src/icon.vue2.js +1 -1
  488. package/lib/packages/components/icon/src/icon.vue2.js.map +1 -1
  489. package/lib/packages/components/import/index.js.map +1 -1
  490. package/lib/packages/components/import/src/import.vue2.js +2 -2
  491. package/lib/packages/components/import/src/import.vue2.js.map +1 -1
  492. package/lib/packages/components/input/index.js.map +1 -1
  493. package/lib/packages/components/input/src/input.vue2.js +2 -2
  494. package/lib/packages/components/input/src/input.vue2.js.map +1 -1
  495. package/lib/packages/components/msg/index.d.js.map +1 -1
  496. package/lib/packages/components/msg/index.js.map +1 -1
  497. package/lib/packages/components/msg/src/msg.vue2.js +15 -15
  498. package/lib/packages/components/msg/src/msg.vue2.js.map +1 -1
  499. package/lib/packages/components/padding/index.js.map +1 -1
  500. package/lib/packages/components/padding/src/padding.vue2.js +1 -1
  501. package/lib/packages/components/padding/src/padding.vue2.js.map +1 -1
  502. package/lib/packages/components/page/index.js.map +1 -1
  503. package/lib/packages/components/page/src/page.vue2.js.map +1 -1
  504. package/lib/packages/components/param/index.d.js.map +1 -1
  505. package/lib/packages/components/param/index.js.map +1 -1
  506. package/lib/packages/components/param/src/Param.vue2.js.map +1 -1
  507. package/lib/packages/components/param/src/ParamItem.vue.js.map +1 -1
  508. package/lib/packages/components/param/src/param-item.js.map +1 -1
  509. package/lib/packages/components/param/src/param.js.map +1 -1
  510. package/lib/packages/components/pic/index.d.js.map +1 -1
  511. package/lib/packages/components/pic/index.js.map +1 -1
  512. package/lib/packages/components/pic/src/Pic.vue2.js +17 -1
  513. package/lib/packages/components/pic/src/Pic.vue2.js.map +1 -1
  514. package/lib/packages/components/pic/src/PicViewer.vue2.js +1 -1
  515. package/lib/packages/components/pic/src/PicViewer.vue2.js.map +1 -1
  516. package/lib/packages/components/pic/src/pic.js +7 -0
  517. package/lib/packages/components/pic/src/pic.js.map +1 -1
  518. package/lib/packages/components/progress/index.d.js.map +1 -1
  519. package/lib/packages/components/progress/index.js.map +1 -1
  520. package/lib/packages/components/progress/src/Progress.vue.js.map +1 -1
  521. package/lib/packages/components/progress/src/Progress.vue2.js.map +1 -1
  522. package/lib/packages/components/progress/src/progress.js.map +1 -1
  523. package/lib/packages/components/range/index.js.map +1 -1
  524. package/lib/packages/components/range/src/range.vue2.js +4 -4
  525. package/lib/packages/components/range/src/range.vue2.js.map +1 -1
  526. package/lib/packages/components/rate/index.js.map +1 -1
  527. package/lib/packages/components/rate/src/rate.vue2.js.map +1 -1
  528. package/lib/packages/components/scroll/index.d.js.map +1 -1
  529. package/lib/packages/components/scroll/index.js.map +1 -1
  530. package/lib/packages/components/scroll/src/Scroll.vue2.js +3 -0
  531. package/lib/packages/components/scroll/src/Scroll.vue2.js.map +1 -1
  532. package/lib/packages/components/scroll/src/ScrollPoint.vue2.js.map +1 -1
  533. package/lib/packages/components/scroll/src/scroll-point.js.map +1 -1
  534. package/lib/packages/components/scroll/src/scroll.js +7 -0
  535. package/lib/packages/components/scroll/src/scroll.js.map +1 -1
  536. package/lib/packages/components/segment/index.js.map +1 -1
  537. package/lib/packages/components/segment/src/segment.vue.js +12 -14
  538. package/lib/packages/components/segment/src/segment.vue.js.map +1 -1
  539. package/lib/packages/components/select/index.js.map +1 -1
  540. package/lib/packages/components/select/src/hooks/use-select-class-style.js.map +1 -1
  541. package/lib/packages/components/select/src/hooks/use-select-option-data.js.map +1 -1
  542. package/lib/packages/components/select/src/select.vue2.js +1 -0
  543. package/lib/packages/components/select/src/select.vue2.js.map +1 -1
  544. package/lib/packages/components/slide/index.js.map +1 -1
  545. package/lib/packages/components/slide/src/slide.vue2.js +1 -1
  546. package/lib/packages/components/slide/src/slide.vue2.js.map +1 -1
  547. package/lib/packages/components/step/index.js.map +1 -1
  548. package/lib/packages/components/step/src/step.vue2.js.map +1 -1
  549. package/lib/packages/components/switch/index.js.map +1 -1
  550. package/lib/packages/components/switch/src/switch.vue2.js.map +1 -1
  551. package/lib/packages/components/tab/index.js.map +1 -1
  552. package/lib/packages/components/tab/src/tab-item.vue2.js +1 -1
  553. package/lib/packages/components/tab/src/tab-item.vue2.js.map +1 -1
  554. package/lib/packages/components/tab/src/tab.vue2.js +7 -7
  555. package/lib/packages/components/tab/src/tab.vue2.js.map +1 -1
  556. package/lib/packages/components/table/index.js.map +1 -1
  557. package/lib/packages/components/table/src/table-body.vue2.js.map +1 -1
  558. package/lib/packages/components/table/src/table-config.vue2.js.map +1 -1
  559. package/lib/packages/components/table/src/table-head.vue2.js +100 -44
  560. package/lib/packages/components/table/src/table-head.vue2.js.map +1 -1
  561. package/lib/packages/components/table/src/table.vue2.js +198 -74
  562. package/lib/packages/components/table/src/table.vue2.js.map +1 -1
  563. package/lib/packages/components/tag/index.d.js.map +1 -1
  564. package/lib/packages/components/tag/index.js.map +1 -1
  565. package/lib/packages/components/tag/src/tag.vue2.js +4 -4
  566. package/lib/packages/components/tag/src/tag.vue2.js.map +1 -1
  567. package/lib/packages/components/text/index.js.map +1 -1
  568. package/lib/packages/components/text/src/text.vue2.js +4 -4
  569. package/lib/packages/components/text/src/text.vue2.js.map +1 -1
  570. package/lib/packages/components/timeline/index.d.js.map +1 -1
  571. package/lib/packages/components/timeline/index.js.map +1 -1
  572. package/lib/packages/components/timeline/src/timeline.vue.js.map +1 -1
  573. package/lib/packages/components/timeline/src/timeline.vue2.js.map +1 -1
  574. package/lib/packages/components/tip/index.d.js.map +1 -1
  575. package/lib/packages/components/tip/index.js.map +1 -1
  576. package/lib/packages/components/tip/src/tip.js.map +1 -1
  577. package/lib/packages/components/tip/src/tip.vue2.js.map +1 -1
  578. package/lib/packages/components/tooltip/index.js.map +1 -1
  579. package/lib/packages/components/tooltip/src/tooltip.js.map +1 -1
  580. package/lib/packages/components/tooltip/src/tooltip.vue2.js.map +1 -1
  581. package/lib/packages/components/transfer/index.js.map +1 -1
  582. package/lib/packages/components/transfer/src/transfer.vue2.js +9 -9
  583. package/lib/packages/components/transfer/src/transfer.vue2.js.map +1 -1
  584. package/lib/packages/components/tree/index.js.map +1 -1
  585. package/lib/packages/components/tree/src/tree-item.vue2.js +27 -26
  586. package/lib/packages/components/tree/src/tree-item.vue2.js.map +1 -1
  587. package/lib/packages/components/tree/src/tree.vue2.js +4 -4
  588. package/lib/packages/components/tree/src/tree.vue2.js.map +1 -1
  589. package/lib/packages/components/upload/index.js.map +1 -1
  590. package/lib/packages/components/upload/src/upload.vue2.js +209 -159
  591. package/lib/packages/components/upload/src/upload.vue2.js.map +1 -1
  592. package/lib/packages/directives/align/index.d.js.map +1 -1
  593. package/lib/packages/directives/align/index.js.map +1 -1
  594. package/lib/packages/directives/align/src/align.d.js.map +1 -1
  595. package/lib/packages/directives/align/src/align.js.map +1 -1
  596. package/lib/packages/directives/color/index.d.js.map +1 -1
  597. package/lib/packages/directives/color/index.js.map +1 -1
  598. package/lib/packages/directives/color/src/color.d.js.map +1 -1
  599. package/lib/packages/directives/color/src/color.js.map +1 -1
  600. package/lib/packages/directives/dis/index.d.js.map +1 -1
  601. package/lib/packages/directives/dis/index.js.map +1 -1
  602. package/lib/packages/directives/dis/src/dis.d.js.map +1 -1
  603. package/lib/packages/directives/dis/src/dis.js.map +1 -1
  604. package/lib/packages/directives/hide/src/hide.js.map +1 -1
  605. package/lib/packages/directives/index.d.js.map +1 -1
  606. package/lib/packages/directives/index.js.map +1 -1
  607. package/lib/packages/directives/loading/index.d.js.map +1 -1
  608. package/lib/packages/directives/loading/index.js.map +1 -1
  609. package/lib/packages/directives/loading/src/loading.d.js.map +1 -1
  610. package/lib/packages/directives/loading/src/loading.js.map +1 -1
  611. package/lib/packages/directives/press/src/press.js.map +1 -1
  612. package/lib/packages/directives/size/index.d.js.map +1 -1
  613. package/lib/packages/directives/size/index.js.map +1 -1
  614. package/lib/packages/directives/size/src/size.d.js.map +1 -1
  615. package/lib/packages/directives/size/src/size.js.map +1 -1
  616. package/lib/packages/directives/tip/index.d.js.map +1 -1
  617. package/lib/packages/directives/tip/index.js.map +1 -1
  618. package/lib/packages/directives/tip/src/tip.d.js.map +1 -1
  619. package/lib/packages/hooks/useDevice.js.map +1 -1
  620. package/lib/packages/hooks/useFormItem.js.map +1 -1
  621. package/lib/packages/hooks/useSetClass.js.map +1 -1
  622. package/lib/packages/hooks/useWidthStyle.js.map +1 -1
  623. package/lib/packages/locale/format.js.map +1 -1
  624. package/lib/packages/locale/index.d.js.map +1 -1
  625. package/lib/packages/locale/index.js.map +1 -1
  626. package/lib/packages/locale/lang/en-US.js.map +1 -1
  627. package/lib/packages/locale/lang/zh-CN.js.map +1 -1
  628. package/lib/packages/resolver/resolver.js.map +1 -1
  629. package/lib/packages/utils/ajax.js.map +1 -1
  630. package/lib/packages/utils/beforeChange.js.map +1 -1
  631. package/lib/packages/utils/compare.d.js.map +1 -1
  632. package/lib/packages/utils/compare.js.map +1 -1
  633. package/lib/packages/utils/config.js.map +1 -1
  634. package/lib/packages/utils/date.js.map +1 -1
  635. package/lib/packages/utils/disabledArea.d.js.map +1 -1
  636. package/lib/packages/utils/disabledArea.js.map +1 -1
  637. package/lib/packages/utils/dom.js.map +1 -1
  638. package/lib/packages/utils/fileAjax.js.map +1 -1
  639. package/lib/packages/utils/isModified.d.js.map +1 -1
  640. package/lib/packages/utils/isModified.js.map +1 -1
  641. package/lib/packages/utils/jsencrypt/JSEncrypt.js.map +1 -1
  642. package/lib/packages/utils/jsencrypt/JSEncryptRSAKey.js.map +1 -1
  643. package/lib/packages/utils/jsencrypt/jselib/asn1js/asn1.js.map +1 -1
  644. package/lib/packages/utils/jsencrypt/jselib/asn1js/base64.js.map +1 -1
  645. package/lib/packages/utils/jsencrypt/jselib/asn1js/hex.js.map +1 -1
  646. package/lib/packages/utils/jsencrypt/jselib/asn1js/int10.js.map +1 -1
  647. package/lib/packages/utils/jsencrypt/jselib/asn1js/oids.js.map +1 -1
  648. package/lib/packages/utils/jsencrypt/jselib/jsbn/base64.js.map +1 -1
  649. package/lib/packages/utils/jsencrypt/jselib/jsbn/jsbn.js.map +1 -1
  650. package/lib/packages/utils/jsencrypt/jselib/jsbn/prng4.js.map +1 -1
  651. package/lib/packages/utils/jsencrypt/jselib/jsbn/rng.js.map +1 -1
  652. package/lib/packages/utils/jsencrypt/jselib/jsbn/rsa.js.map +1 -1
  653. package/lib/packages/utils/jsencrypt/jselib/jsbn/util.js.map +1 -1
  654. package/lib/packages/utils/jsencrypt/jselib/jsrsasign/asn1-1.0.js.map +1 -1
  655. package/lib/packages/utils/jsencrypt/jselib/jsrsasign/yahoo.js.map +1 -1
  656. package/lib/packages/utils/jsencrypt/util.js.map +1 -1
  657. package/lib/packages/utils/md5.js.map +1 -1
  658. package/lib/packages/utils/print.js +1 -1
  659. package/lib/packages/utils/print.js.map +1 -1
  660. package/lib/packages/utils/ratio.js.map +1 -1
  661. package/lib/packages/utils/sign.js.map +1 -1
  662. package/lib/packages/utils/theme.js.map +1 -1
  663. package/lib/packages/utils/types.js.map +1 -1
  664. package/lib/packages/utils/util.js.map +1 -1
  665. package/lib/packages/utils/uuid.js.map +1 -1
  666. package/lib/packages/utils/validate.js.map +1 -1
  667. package/lib/ui/index.d.ts +5 -5
  668. package/package.json +84 -84
  669. package/theme/base.css +0 -3
  670. package/theme/components/index.css +223 -108
  671. package/theme/index.css +223 -108
  672. package/theme/skin/default.css +223 -108
  673. package/es/node_modules/.pnpm/dompurify@3.4.12/node_modules/dompurify/dist/purify.es.mjs +0 -2425
  674. package/es/node_modules/.pnpm/dompurify@3.4.12/node_modules/dompurify/dist/purify.es.mjs.map +0 -1
  675. package/lib/node_modules/.pnpm/dompurify@3.4.12/node_modules/dompurify/dist/purify.es.js +0 -2429
  676. package/lib/node_modules/.pnpm/dompurify@3.4.12/node_modules/dompurify/dist/purify.es.js.map +0 -1
@@ -1,2429 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- /*! @license DOMPurify 3.4.12 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.12/LICENSE */
6
-
7
- function _arrayLikeToArray(r, a) {
8
- (null == a || a > r.length) && (a = r.length);
9
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
10
- return n;
11
- }
12
- function _arrayWithHoles(r) {
13
- if (Array.isArray(r)) return r;
14
- }
15
- function _iterableToArrayLimit(r, l) {
16
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
17
- if (null != t) {
18
- var e,
19
- n,
20
- i,
21
- u,
22
- a = [],
23
- f = true,
24
- o = false;
25
- try {
26
- if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
27
- } catch (r) {
28
- o = true, n = r;
29
- } finally {
30
- try {
31
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
32
- } finally {
33
- if (o) throw n;
34
- }
35
- }
36
- return a;
37
- }
38
- }
39
- function _nonIterableRest() {
40
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
41
- }
42
- function _slicedToArray(r, e) {
43
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
44
- }
45
- function _unsupportedIterableToArray(r, a) {
46
- if (r) {
47
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
48
- var t = {}.toString.call(r).slice(8, -1);
49
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
50
- }
51
- }
52
-
53
- const entries = Object.entries,
54
- setPrototypeOf = Object.setPrototypeOf,
55
- isFrozen = Object.isFrozen,
56
- getPrototypeOf = Object.getPrototypeOf,
57
- getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
58
- let freeze = Object.freeze,
59
- seal = Object.seal,
60
- create = Object.create; // eslint-disable-line import/no-mutable-exports
61
- let _ref = typeof Reflect !== 'undefined' && Reflect,
62
- apply = _ref.apply,
63
- construct = _ref.construct;
64
- if (!freeze) {
65
- freeze = function freeze(x) {
66
- return x;
67
- };
68
- }
69
- if (!seal) {
70
- seal = function seal(x) {
71
- return x;
72
- };
73
- }
74
- if (!apply) {
75
- apply = function apply(func, thisArg) {
76
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
77
- args[_key - 2] = arguments[_key];
78
- }
79
- return func.apply(thisArg, args);
80
- };
81
- }
82
- if (!construct) {
83
- construct = function construct(Func) {
84
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
85
- args[_key2 - 1] = arguments[_key2];
86
- }
87
- return new Func(...args);
88
- };
89
- }
90
- const arrayForEach = unapply(Array.prototype.forEach);
91
- const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
92
- const arrayPop = unapply(Array.prototype.pop);
93
- const arrayPush = unapply(Array.prototype.push);
94
- const arraySplice = unapply(Array.prototype.splice);
95
- const arrayIsArray = Array.isArray;
96
- const stringToLowerCase = unapply(String.prototype.toLowerCase);
97
- const stringToString = unapply(String.prototype.toString);
98
- const stringMatch = unapply(String.prototype.match);
99
- const stringReplace = unapply(String.prototype.replace);
100
- const stringIndexOf = unapply(String.prototype.indexOf);
101
- const stringTrim = unapply(String.prototype.trim);
102
- const numberToString = unapply(Number.prototype.toString);
103
- const booleanToString = unapply(Boolean.prototype.toString);
104
- const bigintToString = typeof BigInt === 'undefined' ? null : unapply(BigInt.prototype.toString);
105
- const symbolToString = typeof Symbol === 'undefined' ? null : unapply(Symbol.prototype.toString);
106
- const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
107
- const objectToString = unapply(Object.prototype.toString);
108
- const regExpTest = unapply(RegExp.prototype.test);
109
- const typeErrorCreate = unconstruct(TypeError);
110
- /**
111
- * Creates a new function that calls the given function with a specified thisArg and arguments.
112
- *
113
- * @param func - The function to be wrapped and called.
114
- * @returns A new function that calls the given function with a specified thisArg and arguments.
115
- */
116
- function unapply(func) {
117
- return function (thisArg) {
118
- if (thisArg instanceof RegExp) {
119
- thisArg.lastIndex = 0;
120
- }
121
- for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
122
- args[_key3 - 1] = arguments[_key3];
123
- }
124
- return apply(func, thisArg, args);
125
- };
126
- }
127
- /**
128
- * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
129
- *
130
- * @param func - The constructor function to be wrapped and called.
131
- * @returns A new function that constructs an instance of the given constructor function with the provided arguments.
132
- */
133
- function unconstruct(Func) {
134
- return function () {
135
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
136
- args[_key4] = arguments[_key4];
137
- }
138
- return construct(Func, args);
139
- };
140
- }
141
- /**
142
- * Add properties to a lookup table
143
- *
144
- * @param set - The set to which elements will be added.
145
- * @param array - The array containing elements to be added to the set.
146
- * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
147
- * @returns The modified set with added elements.
148
- */
149
- function addToSet(set, array) {
150
- let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
151
- if (setPrototypeOf) {
152
- // Make 'in' and truthy checks like Boolean(set.constructor)
153
- // independent of any properties defined on Object.prototype.
154
- // Prevent prototype setters from intercepting set as a this value.
155
- setPrototypeOf(set, null);
156
- }
157
- if (!arrayIsArray(array)) {
158
- return set;
159
- }
160
- let l = array.length;
161
- while (l--) {
162
- let element = array[l];
163
- if (typeof element === 'string') {
164
- const lcElement = transformCaseFunc(element);
165
- if (lcElement !== element) {
166
- // Config presets (e.g. tags.js, attrs.js) are immutable.
167
- if (!isFrozen(array)) {
168
- array[l] = lcElement;
169
- }
170
- element = lcElement;
171
- }
172
- }
173
- set[element] = true;
174
- }
175
- return set;
176
- }
177
- /**
178
- * Clean up an array to harden against CSPP
179
- *
180
- * @param array - The array to be cleaned.
181
- * @returns The cleaned version of the array
182
- */
183
- function cleanArray(array) {
184
- for (let index = 0; index < array.length; index++) {
185
- const isPropertyExist = objectHasOwnProperty(array, index);
186
- if (!isPropertyExist) {
187
- array[index] = null;
188
- }
189
- }
190
- return array;
191
- }
192
- /**
193
- * Shallow clone an object
194
- *
195
- * @param object - The object to be cloned.
196
- * @returns A new object that copies the original.
197
- */
198
- function clone(object) {
199
- const newObject = create(null);
200
- for (const _ref2 of entries(object)) {
201
- var _ref3 = _slicedToArray(_ref2, 2);
202
- const property = _ref3[0];
203
- const value = _ref3[1];
204
- const isPropertyExist = objectHasOwnProperty(object, property);
205
- if (isPropertyExist) {
206
- if (arrayIsArray(value)) {
207
- newObject[property] = cleanArray(value);
208
- } else if (value && typeof value === 'object' && value.constructor === Object) {
209
- newObject[property] = clone(value);
210
- } else {
211
- newObject[property] = value;
212
- }
213
- }
214
- }
215
- return newObject;
216
- }
217
- /**
218
- * Convert non-node values into strings without depending on direct property access.
219
- *
220
- * @param value - The value to stringify.
221
- * @returns A string representation of the provided value.
222
- */
223
- function stringifyValue(value) {
224
- switch (typeof value) {
225
- case 'string':
226
- {
227
- return value;
228
- }
229
- case 'number':
230
- {
231
- return numberToString(value);
232
- }
233
- case 'boolean':
234
- {
235
- return booleanToString(value);
236
- }
237
- case 'bigint':
238
- {
239
- return bigintToString ? bigintToString(value) : '0';
240
- }
241
- case 'symbol':
242
- {
243
- return symbolToString ? symbolToString(value) : 'Symbol()';
244
- }
245
- case 'undefined':
246
- {
247
- return objectToString(value);
248
- }
249
- case 'function':
250
- case 'object':
251
- {
252
- if (value === null) {
253
- return objectToString(value);
254
- }
255
- const valueAsRecord = value;
256
- const valueToString = lookupGetter(valueAsRecord, 'toString');
257
- if (typeof valueToString === 'function') {
258
- const stringified = valueToString(valueAsRecord);
259
- return typeof stringified === 'string' ? stringified : objectToString(stringified);
260
- }
261
- return objectToString(value);
262
- }
263
- default:
264
- {
265
- return objectToString(value);
266
- }
267
- }
268
- }
269
- /**
270
- * This method automatically checks if the prop is function or getter and behaves accordingly.
271
- *
272
- * @param object - The object to look up the getter function in its prototype chain.
273
- * @param prop - The property name for which to find the getter function.
274
- * @returns The getter function found in the prototype chain or a fallback function.
275
- */
276
- function lookupGetter(object, prop) {
277
- while (object !== null) {
278
- const desc = getOwnPropertyDescriptor(object, prop);
279
- if (desc) {
280
- if (desc.get) {
281
- return unapply(desc.get);
282
- }
283
- if (typeof desc.value === 'function') {
284
- return unapply(desc.value);
285
- }
286
- }
287
- object = getPrototypeOf(object);
288
- }
289
- function fallbackValue() {
290
- return null;
291
- }
292
- return fallbackValue;
293
- }
294
- function isRegex(value) {
295
- try {
296
- regExpTest(value, '');
297
- return true;
298
- } catch (_unused) {
299
- return false;
300
- }
301
- }
302
-
303
- 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', 'search', 'section', 'select', 'shadow', 'slot', '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']);
304
- const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
305
- 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']);
306
- // List of SVG elements that are disallowed by default.
307
- // We still need to know them so that we can do namespace
308
- // checks properly in case one wants to add them to
309
- // allow-list.
310
- 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']);
311
- 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']);
312
- // Similarly to SVG, we want to know all MathML elements,
313
- // even those that we disallow by default.
314
- const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
315
- const text = freeze(['#text']);
316
-
317
- const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'command', 'commandfor', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', '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', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns']);
318
- const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', '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', 'dominant-baseline', 'dur', 'edgemode', 'elevation', 'end', 'exponent', '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', 'intercept', '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', 'mask-type', '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', 'slope', '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', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-orientation', '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']);
319
- const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnalign', 'columnlines', 'columnspacing', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lquote', 'lspace', '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']);
320
- const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
321
-
322
- const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
323
- const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
324
- const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
325
- const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
326
- const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
327
- const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
328
- );
329
- const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
330
- const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
331
- );
332
- const DOCTYPE_NAME = seal(/^html$/i);
333
- const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
334
- // Markup-significant character probes used by _sanitizeElements.
335
- // Shared module-level instances are safe despite the sticky /g flags:
336
- // unapply() resets lastIndex for RegExp receivers before every call.
337
- const ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
338
- const COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
339
- const FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
340
- const SELF_CLOSING_TAG = seal(/\/>/i);
341
-
342
- // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
343
- const NODE_TYPE = {
344
- element: 1,
345
- attribute: 2,
346
- text: 3,
347
- cdataSection: 4,
348
- entityReference: 5,
349
- // Deprecated
350
- entityNode: 6,
351
- // Deprecated
352
- processingInstruction: 7,
353
- comment: 8,
354
- document: 9,
355
- documentType: 10,
356
- documentFragment: 11,
357
- notation: 12 // Deprecated
358
- };
359
- const getGlobal = function getGlobal() {
360
- return typeof window === 'undefined' ? null : window;
361
- };
362
- /**
363
- * Creates a no-op policy for internal use only.
364
- * Don't export this function outside this module!
365
- * @param trustedTypes The policy factory.
366
- * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
367
- * @return The policy created (or null, if Trusted Types
368
- * are not supported or creating the policy failed).
369
- */
370
- const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
371
- if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
372
- return null;
373
- }
374
- // Allow the callers to control the unique policy name
375
- // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
376
- // Policy creation with duplicate names throws in Trusted Types.
377
- let suffix = null;
378
- const ATTR_NAME = 'data-tt-policy-suffix';
379
- if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
380
- suffix = purifyHostElement.getAttribute(ATTR_NAME);
381
- }
382
- const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
383
- try {
384
- return trustedTypes.createPolicy(policyName, {
385
- createHTML(html) {
386
- return html;
387
- },
388
- createScriptURL(scriptUrl) {
389
- return scriptUrl;
390
- }
391
- });
392
- } catch (_) {
393
- // Policy creation failed (most likely another DOMPurify script has
394
- // already run). Skip creating the policy, as this will only cause errors
395
- // if TT are enforced.
396
- console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
397
- return null;
398
- }
399
- };
400
- const _createHooksMap = function _createHooksMap() {
401
- return {
402
- afterSanitizeAttributes: [],
403
- afterSanitizeElements: [],
404
- afterSanitizeShadowDOM: [],
405
- beforeSanitizeAttributes: [],
406
- beforeSanitizeElements: [],
407
- beforeSanitizeShadowDOM: [],
408
- uponSanitizeAttribute: [],
409
- uponSanitizeElement: [],
410
- uponSanitizeShadowNode: []
411
- };
412
- };
413
- /**
414
- * Resolve a set-valued configuration option: a fresh set built from
415
- * cfg[key] when it is an own array property (seeded with a clone of
416
- * options.base when given, case-normalized via options.transform),
417
- * the fallback set otherwise.
418
- *
419
- * @param cfg the cloned, prototype-free configuration object
420
- * @param key the configuration property to read
421
- * @param fallback the set to use when the option is absent or not an array
422
- * @param options transform and optional base set to merge into
423
- * @returns the resolved set
424
- */
425
- const _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {
426
- return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
427
- };
428
- function createDOMPurify() {
429
- let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
430
- const DOMPurify = root => createDOMPurify(root);
431
- DOMPurify.version = '3.4.12';
432
- DOMPurify.removed = [];
433
- if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
434
- // Not running in a browser, provide a factory function
435
- // so that you can pass your own Window
436
- DOMPurify.isSupported = false;
437
- return DOMPurify;
438
- }
439
- let document = window.document;
440
- const originalDocument = document;
441
- const currentScript = originalDocument.currentScript;
442
- window.DocumentFragment;
443
- const HTMLTemplateElement = window.HTMLTemplateElement,
444
- Node = window.Node,
445
- Element = window.Element,
446
- NodeFilter = window.NodeFilter,
447
- _window$NamedNodeMap = window.NamedNodeMap;
448
- _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap;
449
- window.HTMLFormElement;
450
- const DOMParser = window.DOMParser,
451
- trustedTypes = window.trustedTypes;
452
- const ElementPrototype = Element.prototype;
453
- const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
454
- const remove = lookupGetter(ElementPrototype, 'remove');
455
- const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
456
- const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
457
- const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
458
- const getShadowRoot = lookupGetter(ElementPrototype, 'shadowRoot');
459
- const getAttributes = lookupGetter(ElementPrototype, 'attributes');
460
- const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeType') : null;
461
- const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeName') : null;
462
- // As per issue #47, the web-components registry is inherited by a
463
- // new document created via createHTMLDocument. As per the spec
464
- // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
465
- // a new empty registry is used when creating a template contents owner
466
- // document, so we use that as our parent document to ensure nothing
467
- // is inherited.
468
- if (typeof HTMLTemplateElement === 'function') {
469
- const template = document.createElement('template');
470
- if (template.content && template.content.ownerDocument) {
471
- document = template.content.ownerDocument;
472
- }
473
- }
474
- let trustedTypesPolicy;
475
- let emptyHTML = '';
476
- // The instance's own internal Trusted Types policy. Unlike a caller-supplied
477
- // `TRUSTED_TYPES_POLICY`, this is created at most once — Trusted Types throws
478
- // on duplicate policy names — and is the only policy allowed to persist
479
- // across configurations and survive `clearConfig()`.
480
- let defaultTrustedTypesPolicy;
481
- let defaultTrustedTypesPolicyResolved = false;
482
- // Tracks whether we are already inside a call to the configured Trusted Types
483
- // policy (`createHTML` or `createScriptURL`). If a supplied policy callback
484
- // itself calls `DOMPurify.sanitize` (the cause of #1422), `sanitize` would
485
- // re-enter the policy and recurse until the stack overflows. We detect that
486
- // re-entry and throw a clear, actionable error instead. The guard is shared
487
- // across both callbacks, because either one re-entering `sanitize` triggers
488
- // the same unbounded recursion.
489
- let IN_TRUSTED_TYPES_POLICY = 0;
490
- const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
491
- if (IN_TRUSTED_TYPES_POLICY > 0) {
492
- throw typeErrorCreate('A configured TRUSTED_TYPES_POLICY callback (createHTML or ' + 'createScriptURL) must not call DOMPurify.sanitize, as that causes ' + 'infinite recursion. Do not pass a policy whose callbacks wrap ' + 'DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted ' + 'Types" section of the README.');
493
- }
494
- };
495
- const _createTrustedHTML = function _createTrustedHTML(html) {
496
- _assertNotInTrustedTypesPolicy();
497
- IN_TRUSTED_TYPES_POLICY++;
498
- try {
499
- return trustedTypesPolicy.createHTML(html);
500
- } finally {
501
- IN_TRUSTED_TYPES_POLICY--;
502
- }
503
- };
504
- const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
505
- _assertNotInTrustedTypesPolicy();
506
- IN_TRUSTED_TYPES_POLICY++;
507
- try {
508
- return trustedTypesPolicy.createScriptURL(scriptUrl);
509
- } finally {
510
- IN_TRUSTED_TYPES_POLICY--;
511
- }
512
- };
513
- // Lazily resolve (and cache) the instance's internal default policy.
514
- // Resolution is attempted at most once: a successful `createPolicy` cannot be
515
- // repeated (Trusted Types throws on duplicate names), and a failed or
516
- // unsupported attempt must not be retried on every parse.
517
- const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
518
- if (!defaultTrustedTypesPolicyResolved) {
519
- defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
520
- defaultTrustedTypesPolicyResolved = true;
521
- }
522
- return defaultTrustedTypesPolicy;
523
- };
524
- const _document = document,
525
- implementation = _document.implementation,
526
- createNodeIterator = _document.createNodeIterator,
527
- createDocumentFragment = _document.createDocumentFragment,
528
- getElementsByTagName = _document.getElementsByTagName;
529
- const importNode = originalDocument.importNode;
530
- let hooks = _createHooksMap();
531
- /**
532
- * Expose whether this browser supports running the full DOMPurify.
533
- */
534
- DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
535
- const MUSTACHE_EXPR$1 = MUSTACHE_EXPR,
536
- ERB_EXPR$1 = ERB_EXPR,
537
- TMPLIT_EXPR$1 = TMPLIT_EXPR,
538
- DATA_ATTR$1 = DATA_ATTR,
539
- ARIA_ATTR$1 = ARIA_ATTR,
540
- IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,
541
- ATTR_WHITESPACE$1 = ATTR_WHITESPACE,
542
- CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
543
- let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
544
- /**
545
- * We consider the elements and attributes below to be safe. Ideally
546
- * don't add any new ones but feel free to remove unwanted ones.
547
- */
548
- /* allowed element names */
549
- let ALLOWED_TAGS = null;
550
- const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
551
- /* Allowed attribute names */
552
- let ALLOWED_ATTR = null;
553
- const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
554
- /*
555
- * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
556
- * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
557
- * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
558
- * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
559
- */
560
- let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
561
- tagNameCheck: {
562
- writable: true,
563
- configurable: false,
564
- enumerable: true,
565
- value: null
566
- },
567
- attributeNameCheck: {
568
- writable: true,
569
- configurable: false,
570
- enumerable: true,
571
- value: null
572
- },
573
- allowCustomizedBuiltInElements: {
574
- writable: true,
575
- configurable: false,
576
- enumerable: true,
577
- value: false
578
- }
579
- }));
580
- /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
581
- let FORBID_TAGS = null;
582
- /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
583
- let FORBID_ATTR = null;
584
- /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */
585
- const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
586
- tagCheck: {
587
- writable: true,
588
- configurable: false,
589
- enumerable: true,
590
- value: null
591
- },
592
- attributeCheck: {
593
- writable: true,
594
- configurable: false,
595
- enumerable: true,
596
- value: null
597
- }
598
- }));
599
- /* Decide if ARIA attributes are okay */
600
- let ALLOW_ARIA_ATTR = true;
601
- /* Decide if custom data attributes are okay */
602
- let ALLOW_DATA_ATTR = true;
603
- /* Decide if unknown protocols are okay */
604
- let ALLOW_UNKNOWN_PROTOCOLS = false;
605
- /* Decide if self-closing tags in attributes are allowed.
606
- * Usually removed due to a mXSS issue in jQuery 3.0 */
607
- let ALLOW_SELF_CLOSE_IN_ATTR = true;
608
- /* Output should be safe for common template engines.
609
- * This means, DOMPurify removes data attributes, mustaches and ERB
610
- */
611
- let SAFE_FOR_TEMPLATES = false;
612
- /* Output should be safe even for XML used within HTML and alike.
613
- * This means, DOMPurify removes comments when containing risky content.
614
- */
615
- let SAFE_FOR_XML = true;
616
- /* Decide if document with <html>... should be returned */
617
- let WHOLE_DOCUMENT = false;
618
- /* Track whether config is already set on this instance of DOMPurify. */
619
- let SET_CONFIG = false;
620
- /* Pristine allowlist bindings captured at setConfig() time. On the
621
- * persistent-config path sanitize() restores the sets from these before
622
- * the per-walk hook clone-guard, so a hook's in-call widening cannot
623
- * carry across calls. Null until setConfig() is called; reset by
624
- * clearConfig(). */
625
- let SET_CONFIG_ALLOWED_TAGS = null;
626
- let SET_CONFIG_ALLOWED_ATTR = null;
627
- /* Decide if all elements (e.g. style, script) must be children of
628
- * document.body. By default, browsers might move them to document.head */
629
- let FORCE_BODY = false;
630
- /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
631
- * string (or a TrustedHTML object if Trusted Types are supported).
632
- * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
633
- */
634
- let RETURN_DOM = false;
635
- /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
636
- * string (or a TrustedHTML object if Trusted Types are supported) */
637
- let RETURN_DOM_FRAGMENT = false;
638
- /* Try to return a Trusted Type object instead of a string, return a string in
639
- * case Trusted Types are not supported */
640
- let RETURN_TRUSTED_TYPE = false;
641
- /* Output should be free from DOM clobbering attacks?
642
- * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
643
- */
644
- let SANITIZE_DOM = true;
645
- /* Achieve full DOM Clobbering protection by isolating the namespace of named
646
- * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
647
- *
648
- * HTML/DOM spec rules that enable DOM Clobbering:
649
- * - Named Access on Window (§7.3.3)
650
- * - DOM Tree Accessors (§3.1.5)
651
- * - Form Element Parent-Child Relations (§4.10.3)
652
- * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
653
- * - HTMLCollection (§4.2.10.2)
654
- *
655
- * Namespace isolation is implemented by prefixing `id` and `name` attributes
656
- * with a constant string, i.e., `user-content-`
657
- */
658
- let SANITIZE_NAMED_PROPS = false;
659
- const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
660
- /* Keep element content when removing element? */
661
- let KEEP_CONTENT = true;
662
- /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
663
- * of importing it into a new Document and returning a sanitized copy */
664
- let IN_PLACE = false;
665
- /* Allow usage of profiles like html, svg and mathMl */
666
- let USE_PROFILES = {};
667
- /* Tags to ignore content of when KEEP_CONTENT is true */
668
- let FORBID_CONTENTS = null;
669
- const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script',
670
- // <selectedcontent> mirrors the selected <option>'s subtree, cloned by
671
- // the UA (customizable <select>) — including any on* handlers — and the
672
- // engine re-mirrors synchronously whenever a removal changes which
673
- // option/selectedcontent is current, even inside DOMPurify's inert
674
- // DOMParser document. Hoisting its children on removal re-inserts a fresh
675
- // mirror target ahead of the walk, which the engine refills, looping
676
- // forever (DoS) and amplifying output. Dropping its content on removal
677
- // (rather than hoisting) breaks that cascade; the content is a duplicate
678
- // of the option, which is sanitized on its own. See campaign-3 F1/F6.
679
- 'selectedcontent', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
680
- /* Tags that are safe for data: URIs */
681
- let DATA_URI_TAGS = null;
682
- const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
683
- /* Attributes safe for values like "javascript:" */
684
- let URI_SAFE_ATTRIBUTES = null;
685
- const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
686
- const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
687
- const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
688
- const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
689
- /* Document namespace */
690
- let NAMESPACE = HTML_NAMESPACE;
691
- let IS_EMPTY_INPUT = false;
692
- /* Allowed XHTML+XML namespaces */
693
- let ALLOWED_NAMESPACES = null;
694
- const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
695
- const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(['mi', 'mo', 'mn', 'ms', 'mtext']);
696
- let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
697
- const DEFAULT_HTML_INTEGRATION_POINTS = freeze(['annotation-xml']);
698
- let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
699
- // Certain elements are allowed in both SVG and HTML
700
- // namespace. We need to specify them explicitly
701
- // so that they don't get erroneously deleted from
702
- // HTML namespace.
703
- const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
704
- /* Parsing of strict XHTML documents */
705
- let PARSER_MEDIA_TYPE = null;
706
- const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
707
- const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
708
- let transformCaseFunc = null;
709
- /* Keep a reference to config to pass to hooks */
710
- let CONFIG = null;
711
- /* Ideally, do not touch anything below this line */
712
- /* ______________________________________________ */
713
- const formElement = document.createElement('form');
714
- const isRegexOrFunction = function isRegexOrFunction(testValue) {
715
- return testValue instanceof RegExp || testValue instanceof Function;
716
- };
717
- /**
718
- * _parseConfig
719
- *
720
- * @param cfg optional config literal
721
- */
722
- // eslint-disable-next-line complexity
723
- const _parseConfig = function _parseConfig() {
724
- let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
725
- if (CONFIG && CONFIG === cfg) {
726
- return;
727
- }
728
- /* Shield configuration object from tampering */
729
- if (!cfg || typeof cfg !== 'object') {
730
- cfg = {};
731
- }
732
- /* Shield configuration object from prototype pollution */
733
- cfg = clone(cfg);
734
- PARSER_MEDIA_TYPE =
735
- // eslint-disable-next-line unicorn/prefer-includes
736
- SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
737
- // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
738
- transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
739
- /* Set configuration parameters */
740
- ALLOWED_TAGS = _resolveSetOption(cfg, 'ALLOWED_TAGS', DEFAULT_ALLOWED_TAGS, {
741
- transform: transformCaseFunc
742
- });
743
- ALLOWED_ATTR = _resolveSetOption(cfg, 'ALLOWED_ATTR', DEFAULT_ALLOWED_ATTR, {
744
- transform: transformCaseFunc
745
- });
746
- ALLOWED_NAMESPACES = _resolveSetOption(cfg, 'ALLOWED_NAMESPACES', DEFAULT_ALLOWED_NAMESPACES, {
747
- transform: stringToString
748
- });
749
- URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, 'ADD_URI_SAFE_ATTR', DEFAULT_URI_SAFE_ATTRIBUTES, {
750
- transform: transformCaseFunc,
751
- base: DEFAULT_URI_SAFE_ATTRIBUTES
752
- });
753
- DATA_URI_TAGS = _resolveSetOption(cfg, 'ADD_DATA_URI_TAGS', DEFAULT_DATA_URI_TAGS, {
754
- transform: transformCaseFunc,
755
- base: DEFAULT_DATA_URI_TAGS
756
- });
757
- FORBID_CONTENTS = _resolveSetOption(cfg, 'FORBID_CONTENTS', DEFAULT_FORBID_CONTENTS, {
758
- transform: transformCaseFunc
759
- });
760
- FORBID_TAGS = _resolveSetOption(cfg, 'FORBID_TAGS', clone({}), {
761
- transform: transformCaseFunc
762
- });
763
- FORBID_ATTR = _resolveSetOption(cfg, 'FORBID_ATTR', clone({}), {
764
- transform: transformCaseFunc
765
- });
766
- USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
767
- ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
768
- ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
769
- ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
770
- ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
771
- SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
772
- SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
773
- WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
774
- RETURN_DOM = cfg.RETURN_DOM || false; // Default false
775
- RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
776
- RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
777
- FORCE_BODY = cfg.FORCE_BODY || false; // Default false
778
- SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
779
- SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
780
- KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
781
- IN_PLACE = cfg.IN_PLACE || false; // Default false
782
- IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp
783
- NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace
784
- MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'MATHML_TEXT_INTEGRATION_POINTS') && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === 'object' ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS); // Default built-in map
785
- HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'HTML_INTEGRATION_POINTS') && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === 'object' ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS); // Default built-in map
786
- const customElementHandling = objectHasOwnProperty(cfg, 'CUSTOM_ELEMENT_HANDLING') && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === 'object' ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
787
- CUSTOM_ELEMENT_HANDLING = create(null);
788
- if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {
789
- CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck; // Default undefined
790
- }
791
- if (objectHasOwnProperty(customElementHandling, 'attributeNameCheck') && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
792
- CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck; // Default undefined
793
- }
794
- if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {
795
- CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined
796
- }
797
- seal(CUSTOM_ELEMENT_HANDLING);
798
- if (SAFE_FOR_TEMPLATES) {
799
- ALLOW_DATA_ATTR = false;
800
- }
801
- if (RETURN_DOM_FRAGMENT) {
802
- RETURN_DOM = true;
803
- }
804
- /* Parse profile info */
805
- if (USE_PROFILES) {
806
- ALLOWED_TAGS = addToSet({}, text);
807
- ALLOWED_ATTR = create(null);
808
- if (USE_PROFILES.html === true) {
809
- addToSet(ALLOWED_TAGS, html$1);
810
- addToSet(ALLOWED_ATTR, html);
811
- }
812
- if (USE_PROFILES.svg === true) {
813
- addToSet(ALLOWED_TAGS, svg$1);
814
- addToSet(ALLOWED_ATTR, svg);
815
- addToSet(ALLOWED_ATTR, xml);
816
- }
817
- if (USE_PROFILES.svgFilters === true) {
818
- addToSet(ALLOWED_TAGS, svgFilters);
819
- addToSet(ALLOWED_ATTR, svg);
820
- addToSet(ALLOWED_ATTR, xml);
821
- }
822
- if (USE_PROFILES.mathMl === true) {
823
- addToSet(ALLOWED_TAGS, mathMl$1);
824
- addToSet(ALLOWED_ATTR, mathMl);
825
- addToSet(ALLOWED_ATTR, xml);
826
- }
827
- }
828
- /* Always reset function-based ADD_TAGS / ADD_ATTR checks to prevent
829
- * leaking across calls when switching from function to array config */
830
- EXTRA_ELEMENT_HANDLING.tagCheck = null;
831
- EXTRA_ELEMENT_HANDLING.attributeCheck = null;
832
- /* Merge configuration parameters */
833
- if (objectHasOwnProperty(cfg, 'ADD_TAGS')) {
834
- if (typeof cfg.ADD_TAGS === 'function') {
835
- EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
836
- } else if (arrayIsArray(cfg.ADD_TAGS)) {
837
- if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
838
- ALLOWED_TAGS = clone(ALLOWED_TAGS);
839
- }
840
- addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
841
- }
842
- }
843
- if (objectHasOwnProperty(cfg, 'ADD_ATTR')) {
844
- if (typeof cfg.ADD_ATTR === 'function') {
845
- EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
846
- } else if (arrayIsArray(cfg.ADD_ATTR)) {
847
- if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
848
- ALLOWED_ATTR = clone(ALLOWED_ATTR);
849
- }
850
- addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
851
- }
852
- }
853
- if (objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
854
- addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
855
- }
856
- if (objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS)) {
857
- if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
858
- FORBID_CONTENTS = clone(FORBID_CONTENTS);
859
- }
860
- addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
861
- }
862
- if (objectHasOwnProperty(cfg, 'ADD_FORBID_CONTENTS') && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
863
- if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
864
- FORBID_CONTENTS = clone(FORBID_CONTENTS);
865
- }
866
- addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
867
- }
868
- /* Add #text in case KEEP_CONTENT is set to true */
869
- if (KEEP_CONTENT) {
870
- ALLOWED_TAGS['#text'] = true;
871
- }
872
- /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
873
- if (WHOLE_DOCUMENT) {
874
- addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
875
- }
876
- /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
877
- if (ALLOWED_TAGS.table) {
878
- addToSet(ALLOWED_TAGS, ['tbody']);
879
- delete FORBID_TAGS.tbody;
880
- }
881
- // Re-derive the active Trusted Types policy from this configuration on
882
- // every parse. The active policy must never be sticky closure state that
883
- // outlives the config that set it: a caller-supplied policy left in place
884
- // after `clearConfig()` — or after a later call that supplied none, or
885
- // `TRUSTED_TYPES_POLICY: null` — could sign a subsequent "default"
886
- // `RETURN_TRUSTED_TYPE` result with a foreign, possibly unsafe policy.
887
- // See GHSA-vxr8-fq34-vvx9.
888
- if (cfg.TRUSTED_TYPES_POLICY) {
889
- if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
890
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
891
- }
892
- if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
893
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
894
- }
895
- // A caller-supplied policy applies to this configuration only.
896
- const previousTrustedTypesPolicy = trustedTypesPolicy;
897
- trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
898
- // Sign local variables required by `sanitize`. If the supplied policy's
899
- // `createHTML` is circular (i.e. it calls `DOMPurify.sanitize`), this
900
- // throws via the re-entrancy guard. Restore the previous policy first so
901
- // the instance is not left in a poisoned state. See #1422.
902
- try {
903
- emptyHTML = _createTrustedHTML('');
904
- } catch (error) {
905
- trustedTypesPolicy = previousTrustedTypesPolicy;
906
- throw error;
907
- }
908
- } else if (cfg.TRUSTED_TYPES_POLICY === null) {
909
- // Explicit opt-out for this call: perform no Trusted Types signing and
910
- // create nothing (so a strict `trusted-types` CSP that disallows a
911
- // `dompurify` policy can still call `sanitize` from inside its own
912
- // policy — see #1422). Resetting to `undefined` rather than a sticky
913
- // `null` also drops any previously retained caller policy, so it cannot
914
- // resurface on a later call, while still allowing the next config-less
915
- // call to restore the internal default policy. See GHSA-vxr8-fq34-vvx9.
916
- trustedTypesPolicy = undefined;
917
- emptyHTML = '';
918
- } else {
919
- // No policy supplied: keep the currently active policy if one is set — a
920
- // previously supplied policy is intentionally sticky across config-less
921
- // calls — otherwise fall back to the instance's own internal policy,
922
- // created at most once. (A policy supplied for a *single* call still
923
- // lingers by design; what must not linger is a policy whose configuration
924
- // has been torn down via `clearConfig()`, which restores the default.)
925
- if (trustedTypesPolicy === undefined) {
926
- trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
927
- }
928
- // Sign internal variables only when a policy is active. A falsy policy
929
- // (Trusted Types unsupported, creation failed, or an explicit opt-out)
930
- // leaves `emptyHTML` as a plain string, so we never call `.createHTML` on
931
- // a non-policy and throw. See #1422.
932
- if (trustedTypesPolicy && typeof emptyHTML === 'string') {
933
- emptyHTML = _createTrustedHTML('');
934
- }
935
- }
936
- // Prevent further manipulation of configuration.
937
- // Not available in IE8, Safari 5, etc.
938
- if (freeze) {
939
- freeze(cfg);
940
- }
941
- CONFIG = cfg;
942
- };
943
- /* Keep track of all possible SVG and MathML tags
944
- * so that we can perform the namespace checks
945
- * correctly. */
946
- const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
947
- const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
948
- /**
949
- * Namespace rules for an element in the SVG namespace.
950
- *
951
- * @param tagName the element's lowercase tag name
952
- * @param parent the (possibly simulated) parent node
953
- * @param parentTagName the parent's lowercase tag name
954
- * @returns true if a spec-compliant parser could produce this element
955
- */
956
- const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {
957
- // The only way to switch from HTML namespace to SVG
958
- // is via <svg>. If it happens via any other tag, then
959
- // it should be killed.
960
- if (parent.namespaceURI === HTML_NAMESPACE) {
961
- return tagName === 'svg';
962
- }
963
- // The only way to switch from MathML to SVG is via <svg>
964
- // if the parent is either <annotation-xml> or a MathML
965
- // text integration point.
966
- if (parent.namespaceURI === MATHML_NAMESPACE) {
967
- return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
968
- }
969
- // We only allow elements that are defined in SVG
970
- // spec. All others are disallowed in SVG namespace.
971
- return Boolean(ALL_SVG_TAGS[tagName]);
972
- };
973
- /**
974
- * Namespace rules for an element in the MathML namespace.
975
- *
976
- * @param tagName the element's lowercase tag name
977
- * @param parent the (possibly simulated) parent node
978
- * @param parentTagName the parent's lowercase tag name
979
- * @returns true if a spec-compliant parser could produce this element
980
- */
981
- const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {
982
- // The only way to switch from HTML namespace to MathML
983
- // is via <math>. If it happens via any other tag, then
984
- // it should be killed.
985
- if (parent.namespaceURI === HTML_NAMESPACE) {
986
- return tagName === 'math';
987
- }
988
- // The only way to switch from SVG to MathML is via
989
- // <math> and HTML integration points
990
- if (parent.namespaceURI === SVG_NAMESPACE) {
991
- return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
992
- }
993
- // We only allow elements that are defined in MathML
994
- // spec. All others are disallowed in MathML namespace.
995
- return Boolean(ALL_MATHML_TAGS[tagName]);
996
- };
997
- /**
998
- * Namespace rules for an element in the HTML namespace.
999
- *
1000
- * @param tagName the element's lowercase tag name
1001
- * @param parent the (possibly simulated) parent node
1002
- * @param parentTagName the parent's lowercase tag name
1003
- * @returns true if a spec-compliant parser could produce this element
1004
- */
1005
- const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {
1006
- // The only way to switch from SVG to HTML is via
1007
- // HTML integration points, and from MathML to HTML
1008
- // is via MathML text integration points
1009
- if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
1010
- return false;
1011
- }
1012
- if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
1013
- return false;
1014
- }
1015
- // We disallow tags that are specific for MathML
1016
- // or SVG and should never appear in HTML namespace
1017
- return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
1018
- };
1019
- /**
1020
- * @param element a DOM element whose namespace is being checked
1021
- * @returns Return false if the element has a
1022
- * namespace that a spec-compliant parser would never
1023
- * return. Return true otherwise.
1024
- */
1025
- const _checkValidNamespace = function _checkValidNamespace(element) {
1026
- let parent = getParentNode(element);
1027
- // In JSDOM, if we're inside shadow DOM, then parentNode
1028
- // can be null. We just simulate parent in this case.
1029
- if (!parent || !parent.tagName) {
1030
- parent = {
1031
- namespaceURI: NAMESPACE,
1032
- tagName: 'template'
1033
- };
1034
- }
1035
- const tagName = stringToLowerCase(element.tagName);
1036
- const parentTagName = stringToLowerCase(parent.tagName);
1037
- if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
1038
- return false;
1039
- }
1040
- if (element.namespaceURI === SVG_NAMESPACE) {
1041
- return _checkSvgNamespace(tagName, parent, parentTagName);
1042
- }
1043
- if (element.namespaceURI === MATHML_NAMESPACE) {
1044
- return _checkMathMlNamespace(tagName, parent, parentTagName);
1045
- }
1046
- if (element.namespaceURI === HTML_NAMESPACE) {
1047
- return _checkHtmlNamespace(tagName, parent, parentTagName);
1048
- }
1049
- // For XHTML and XML documents that support custom namespaces
1050
- if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
1051
- return true;
1052
- }
1053
- // The code should never reach this place (this means
1054
- // that the element somehow got namespace that is not
1055
- // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
1056
- // Return false just in case.
1057
- return false;
1058
- };
1059
- /**
1060
- * _forceRemove
1061
- *
1062
- * @param node a DOM node
1063
- */
1064
- const _forceRemove = function _forceRemove(node) {
1065
- arrayPush(DOMPurify.removed, {
1066
- element: node
1067
- });
1068
- try {
1069
- // eslint-disable-next-line unicorn/prefer-dom-node-remove
1070
- getParentNode(node).removeChild(node);
1071
- } catch (_) {
1072
- /* The normal detach failed — this is reached for a parentless node
1073
- (getParentNode() is null, so .removeChild throws). Element.prototype
1074
- .remove() is itself a spec no-op on a parentless node, so a recorded
1075
- "removal" would otherwise hand the caller back an intact,
1076
- payload-bearing node (e.g. a detached IN_PLACE root the mXSS canary or
1077
- the style-with-element-child rule decided to kill). Fail closed by
1078
- throwing — exactly as a clobbered root does at the IN_PLACE entry —
1079
- rather than trying to "neutralize" the node via its own methods.
1080
- Neutralizing would mean calling getAttributeNames()/removeAttribute()
1081
- on the node, both of which a <form> root can clobber via a named child
1082
- (and _isClobbered does not even probe getAttributeNames), so the
1083
- neutralize step could itself be silently defeated, leaving the payload
1084
- intact. A throw touches only the cached, clobber-safe remove() and
1085
- getParentNode(). Generalizes GHSA-r47g-fvhr-h676 (clobbered-form root)
1086
- to every root-kill reason. REPORT-3.
1087
- This lives inside the catch, so it never fires for a normally-removed
1088
- in-tree node: those have a parent, removeChild() succeeds, and the
1089
- catch is not entered. Only a kept (parentless) root reaches here. */
1090
- remove(node);
1091
- if (!getParentNode(node)) {
1092
- throw typeErrorCreate('a node selected for removal could not be detached from its tree ' + 'and cannot be safely returned; refusing to sanitize in place');
1093
- }
1094
- }
1095
- };
1096
- /**
1097
- * _neutralizeRoot
1098
- *
1099
- * Fail-closed teardown of an in-place root after the sanitize walk aborts
1100
- * (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered
1101
- * custom element's reaction detaches a node so `_forceRemove`'s deliberate
1102
- * parentless guard throws, or any other re-entrant engine mutation — would
1103
- * otherwise leave the caller's *live* tree half-sanitized, with everything
1104
- * after the abort point still carrying its handlers. There is no safe way
1105
- * to resume the walk (the tree mutated under us), so we strip the root bare:
1106
- * remove every child and every attribute, then let the caller's catch see
1107
- * the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`
1108
- * getters; the root was already clobber-pre-flighted at the IN_PLACE entry).
1109
- *
1110
- * @param root the in-place root to empty
1111
- */
1112
- const _neutralizeRoot = function _neutralizeRoot(root) {
1113
- /* Strip every disallowed attribute (on* handlers included) off the whole
1114
- subtree BEFORE detaching anything. Detaching first would hand back
1115
- handler-bearing originals (e.g. an already-loading `<img onerror>`)
1116
- whose queued resource event still fires in page scope after we throw.
1117
- Clobber-safe reads; a doomed clobbered node's own attributes are
1118
- irrelevant while its non-clobbered descendants are reached and scrubbed. */
1119
- _neutralizeSubtree(root);
1120
- const childNodes = getChildNodes(root);
1121
- if (childNodes) {
1122
- const snapshot = [];
1123
- arrayForEach(childNodes, child => {
1124
- arrayPush(snapshot, child);
1125
- });
1126
- arrayForEach(snapshot, child => {
1127
- try {
1128
- remove(child);
1129
- } catch (_) {
1130
- /* Best-effort teardown; a still-attached child is handled below */
1131
- }
1132
- });
1133
- }
1134
- const attributes = getAttributes(root);
1135
- if (attributes) {
1136
- for (let i = attributes.length - 1; i >= 0; --i) {
1137
- const attribute = attributes[i];
1138
- const name = attribute && attribute.name;
1139
- if (typeof name === 'string') {
1140
- try {
1141
- root.removeAttribute(name);
1142
- } catch (_) {
1143
- /* Clobbered removeAttribute — ignore (fail-closed best effort) */
1144
- }
1145
- }
1146
- }
1147
- }
1148
- };
1149
- /**
1150
- * _removeAttribute
1151
- *
1152
- * @param name an Attribute name
1153
- * @param element a DOM node
1154
- */
1155
- const _removeAttribute = function _removeAttribute(name, element) {
1156
- try {
1157
- arrayPush(DOMPurify.removed, {
1158
- attribute: element.getAttributeNode(name),
1159
- from: element
1160
- });
1161
- } catch (_) {
1162
- arrayPush(DOMPurify.removed, {
1163
- attribute: null,
1164
- from: element
1165
- });
1166
- }
1167
- element.removeAttribute(name);
1168
- // We void attribute values for unremovable "is" attributes
1169
- if (name === 'is') {
1170
- if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
1171
- try {
1172
- _forceRemove(element);
1173
- } catch (_) {}
1174
- } else {
1175
- try {
1176
- element.setAttribute(name, '');
1177
- } catch (_) {}
1178
- }
1179
- }
1180
- };
1181
- /**
1182
- * _stripDisallowedAttributes
1183
- *
1184
- * Removes every attribute the active configuration does not allow from a
1185
- * single element, using the same allowlist as the main attribute pass (so
1186
- * `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to
1187
- * neutralise nodes that are being discarded from an in-place tree.
1188
- *
1189
- * @param element the element to strip
1190
- */
1191
- const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {
1192
- const attributes = getAttributes(element);
1193
- if (!attributes) {
1194
- return;
1195
- }
1196
- for (let i = attributes.length - 1; i >= 0; --i) {
1197
- const attribute = attributes[i];
1198
- const name = attribute && attribute.name;
1199
- if (typeof name !== 'string' || ALLOWED_ATTR[transformCaseFunc(name)]) {
1200
- continue;
1201
- }
1202
- try {
1203
- element.removeAttribute(name);
1204
- } catch (_) {
1205
- /* Clobbered removeAttribute on a doomed node — ignore */
1206
- }
1207
- }
1208
- };
1209
- /**
1210
- * _neutralizeSubtree
1211
- *
1212
- * Completes the audit-5 F1 fix across every removal path. The KEEP_CONTENT
1213
- * move-hoist neutralises only disallowed-tag removals; clobber, mXSS-canary,
1214
- * namespace, comment, processing-instruction and KEEP_CONTENT:false removals
1215
- * all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path
1216
- * those dropped nodes are detached from the caller's LIVE tree but a
1217
- * handler-bearing original among them (an `<img onerror>`/`<video>` that was
1218
- * loading) keeps its queued resource event, which fires in page scope after
1219
- * sanitize returns. This walks a removed subtree and strips every attribute
1220
- * the active configuration does not allow — so `on*` handlers are cancelled
1221
- * through the SAME allowlist that governs kept nodes, not a separate `/^on/`
1222
- * blocklist. Run synchronously before sanitize returns, i.e. before any
1223
- * queued event can fire. Hook-free by design: these nodes leave the output,
1224
- * so firing attribute hooks for them would be surprising. Clobber-safe reads;
1225
- * a doomed clobbered node may shadow `removeAttribute` (its own attributes are
1226
- * irrelevant — it is discarded — while its non-clobbered descendants, e.g.
1227
- * the `<img>`, are reached and scrubbed).
1228
- *
1229
- * @param root the root of a removed subtree to neutralise
1230
- */
1231
- const _neutralizeSubtree = function _neutralizeSubtree(root) {
1232
- const stack = [root];
1233
- while (stack.length > 0) {
1234
- const node = stack.pop();
1235
- const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
1236
- if (nodeType === NODE_TYPE.element) {
1237
- _stripDisallowedAttributes(node);
1238
- }
1239
- const childNodes = getChildNodes(node);
1240
- if (childNodes) {
1241
- for (let i = childNodes.length - 1; i >= 0; --i) {
1242
- stack.push(childNodes[i]);
1243
- }
1244
- }
1245
- }
1246
- };
1247
- /**
1248
- * _neutralizePatchLinkage
1249
- *
1250
- * IN_PLACE entry pre-pass (declarative-partial-updates / streaming
1251
- * hardening, https://github.com/WICG/declarative-partial-updates).
1252
- *
1253
- * The main walk strips patch linkage (`for`/`patchsrc`) and removes range
1254
- * markers (PIs / markup comments) node-by-node, in document order, AS it
1255
- * reaches each node. On a live in-place root that leaves a window: from the
1256
- * moment the root is connected until the walk arrives at a given node, that
1257
- * node's linkage is live. A patch applied on connection/stream can fire as
1258
- * a microtask during the walk and inject or teleport an unsanitized DOM
1259
- * range into a region the iterator has already passed and will not revisit,
1260
- * so the post-return "tree is sanitized" contract is violated. Sweep the
1261
- * whole tree once up front and sever every linkage before the walk begins,
1262
- * closing that window.
1263
- *
1264
- * This CANNOT undo a patch that already fired before sanitize ran — that is
1265
- * the irreducible "do not IN_PLACE a live-connected attacker tree" caveat —
1266
- * but it closes everything from sanitize-start onward. Gated on SAFE_FOR_XML
1267
- * to group with the rest of the declarative-partial-updates handling and
1268
- * stay overridable, consistent with the codebase.
1269
- *
1270
- * Clobber-safe traversal (cached childNodes getter); per-node try/catch so a
1271
- * clobbered root cannot defeat the sweep of its non-clobbered descendants.
1272
- *
1273
- * NOTE (pending real-Chrome confirmation, see test/declarative-patch-probe
1274
- * .html Q1): this mirrors the existing policy of keeping `for` on
1275
- * <label>/<output>. If the shipping feature can drive a patch through a
1276
- * surviving `for`-on-label/output + `id` pair, this pre-pass and the
1277
- * attribute check at _isBasicCustomElement's caller must additionally drop
1278
- * that pair on the IN_PLACE path. Left as-is until the taxonomy is verified.
1279
- *
1280
- * @param root the in-place root to sweep
1281
- */
1282
- const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {
1283
- if (!SAFE_FOR_XML) {
1284
- return;
1285
- }
1286
- const stack = [root];
1287
- while (stack.length > 0) {
1288
- const node = stack.pop();
1289
- const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
1290
- /* Remove range markers (the target side of a patch linkage): every
1291
- processing instruction, and any markup-bearing comment. */
1292
- if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
1293
- try {
1294
- remove(node);
1295
- } catch (_) {
1296
- /* Best-effort */
1297
- }
1298
- continue;
1299
- }
1300
- /* Strip patch-source attributes (the source side) off elements. */
1301
- if (nodeType === NODE_TYPE.element) {
1302
- const element = node;
1303
- const lcTag = transformCaseFunc(getNodeName ? getNodeName(node) : node.nodeName);
1304
- try {
1305
- if (element.hasAttribute && element.hasAttribute('patchsrc')) {
1306
- element.removeAttribute('patchsrc');
1307
- }
1308
- if (element.hasAttribute && element.hasAttribute('for') && lcTag !== 'label' && lcTag !== 'output') {
1309
- element.removeAttribute('for');
1310
- }
1311
- } catch (_) {
1312
- /* Clobbered removeAttribute/hasAttribute on a doomed node — ignore */
1313
- }
1314
- }
1315
- const childNodes = getChildNodes(node);
1316
- if (childNodes) {
1317
- for (let i = childNodes.length - 1; i >= 0; --i) {
1318
- stack.push(childNodes[i]);
1319
- }
1320
- }
1321
- }
1322
- };
1323
- /**
1324
- * _initDocument
1325
- *
1326
- * @param dirty - a string of dirty markup
1327
- * @return a DOM, filled with the dirty markup
1328
- */
1329
- const _initDocument = function _initDocument(dirty) {
1330
- /* Create a HTML document */
1331
- let doc = null;
1332
- let leadingWhitespace = null;
1333
- if (FORCE_BODY) {
1334
- dirty = '<remove></remove>' + dirty;
1335
- } else {
1336
- /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
1337
- const matches = stringMatch(dirty, /^[\r\n\t ]+/);
1338
- leadingWhitespace = matches && matches[0];
1339
- }
1340
- if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
1341
- // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
1342
- dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
1343
- }
1344
- const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
1345
- /*
1346
- * Use the DOMParser API by default, fallback later if needs be
1347
- * DOMParser not work for svg when has multiple root element.
1348
- */
1349
- if (NAMESPACE === HTML_NAMESPACE) {
1350
- try {
1351
- doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
1352
- } catch (_) {}
1353
- }
1354
- /* Use createHTMLDocument in case DOMParser is not available */
1355
- if (!doc || !doc.documentElement) {
1356
- doc = implementation.createDocument(NAMESPACE, 'template', null);
1357
- try {
1358
- doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
1359
- } catch (_) {
1360
- // Syntax error if dirtyPayload is invalid xml
1361
- }
1362
- }
1363
- const body = doc.body || doc.documentElement;
1364
- if (dirty && leadingWhitespace) {
1365
- body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
1366
- }
1367
- /* Work on whole document or just its body */
1368
- if (NAMESPACE === HTML_NAMESPACE) {
1369
- return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
1370
- }
1371
- return WHOLE_DOCUMENT ? doc.documentElement : body;
1372
- };
1373
- /**
1374
- * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
1375
- *
1376
- * @param root The root element or node to start traversing on.
1377
- * @return The created NodeIterator
1378
- */
1379
- const _createNodeIterator = function _createNodeIterator(root) {
1380
- return createNodeIterator.call(root.ownerDocument || root, root,
1381
- // eslint-disable-next-line no-bitwise
1382
- NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
1383
- };
1384
- /**
1385
- * Replace template expression syntax (mustache, ERB, template
1386
- * literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub
1387
- * sites. Order matters: mustache, then ERB, then template literal.
1388
- *
1389
- * @param value the string to scrub
1390
- * @returns the scrubbed string
1391
- */
1392
- const _stripTemplateExpressions = function _stripTemplateExpressions(value) {
1393
- value = stringReplace(value, MUSTACHE_EXPR$1, ' ');
1394
- value = stringReplace(value, ERB_EXPR$1, ' ');
1395
- value = stringReplace(value, TMPLIT_EXPR$1, ' ');
1396
- return value;
1397
- };
1398
- /**
1399
- * Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
1400
- * character data of an element subtree. Used as the final safety net for
1401
- * SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions
1402
- * which only form after text-node normalization (e.g. fragments split across
1403
- * stripped elements) cannot survive into a template-evaluating framework.
1404
- *
1405
- * Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`
1406
- * in place rather than round-tripping through innerHTML. This preserves
1407
- * descendant node references (important for IN_PLACE callers), avoids a
1408
- * serialize/reparse cycle, and reads literal character data — which means
1409
- * `<%...%>` in text content matches the ERB regex against its real bytes
1410
- * instead of the HTML-entity-escaped form innerHTML would produce.
1411
- *
1412
- * Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for
1413
- * attributes is performed during the per-node `_sanitizeAttributes` pass.
1414
- *
1415
- * @param node The root element whose character data should be scrubbed.
1416
- */
1417
- const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
1418
- var _node$querySelectorAl;
1419
- node.normalize();
1420
- const walker = createNodeIterator.call(node.ownerDocument || node, node,
1421
- // eslint-disable-next-line no-bitwise
1422
- NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
1423
- let currentNode = walker.nextNode();
1424
- while (currentNode) {
1425
- currentNode.data = _stripTemplateExpressions(currentNode.data);
1426
- currentNode = walker.nextNode();
1427
- }
1428
- // NodeIterator does not descend into <template>.content per the DOM spec,
1429
- // so we must explicitly recurse into each template's content fragment,
1430
- // mirroring the approach used by _sanitizeShadowDOM.
1431
- const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, 'template');
1432
- if (templates) {
1433
- arrayForEach(templates, tmpl => {
1434
- if (_isDocumentFragment(tmpl.content)) {
1435
- _scrubTemplateExpressions2(tmpl.content);
1436
- }
1437
- });
1438
- }
1439
- };
1440
- /**
1441
- * _isClobbered
1442
- *
1443
- * Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
1444
- * interface with [LegacyOverrideBuiltIns]; a descendant element with a
1445
- * `name` attribute matching a prototype property shadows that property
1446
- * on direct reads. We use this check at the IN_PLACE entry-point and
1447
- * during attribute sanitization to refuse clobbered forms.
1448
- *
1449
- * @param element element to check for clobbering attacks
1450
- * @return true if clobbered, false if safe
1451
- */
1452
- const _isClobbered = function _isClobbered(element) {
1453
- // Realm-independent tag-name probe. If we can't determine the tag
1454
- // name at all, we can't reason about clobbering — return false
1455
- // (the caller's other defences still apply).
1456
- const realTagName = getNodeName ? getNodeName(element) : null;
1457
- if (typeof realTagName !== 'string') {
1458
- return false;
1459
- }
1460
- if (transformCaseFunc(realTagName) !== 'form') {
1461
- return false;
1462
- }
1463
- return typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' ||
1464
- // Realm-safe NamedNodeMap detection: equality against the cached
1465
- // prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
1466
- // makes the direct read diverge from the cached read; a clean form
1467
- // (same-realm OR foreign-realm) has both reads pointing at the same
1468
- // canonical NamedNodeMap.
1469
- element.attributes !== getAttributes(element) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function' ||
1470
- // NodeType clobbering probe. Cached Node.prototype.nodeType getter
1471
- // returns the integer 1 for any Element regardless of realm; direct
1472
- // read on a clobbered form (e.g. <input name="nodeType">) returns
1473
- // the named child element. Cheap addition — nodeType is read from
1474
- // an internal slot, no serialization cost — and removes a residual
1475
- // clobbering surface used by several mXSS / PI / comment branches
1476
- // in _sanitizeElements that compare currentNode.nodeType directly.
1477
- element.nodeType !== getNodeType(element) ||
1478
- // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
1479
- // "childNodes" shadows the prototype getter. Direct reads of
1480
- // form.childNodes from a clobbered form return the named child
1481
- // instead of the real NodeList, so any walk that reads it directly
1482
- // skips the form's real children. Compare the direct read to the
1483
- // cached Node.prototype getter — when the form's named-property
1484
- // getter intercepts the read, the two values differ and we flag
1485
- // the form. This catches every clobbering child type (input,
1486
- // select, etc.) regardless of whether the named child happens to
1487
- // carry a numeric .length, which a typeof-based probe would miss
1488
- // (e.g. HTMLSelectElement.length is a defined unsigned-long).
1489
- element.childNodes !== getChildNodes(element);
1490
- };
1491
- /**
1492
- * Checks whether the given value is a DocumentFragment from any realm.
1493
- *
1494
- * The realm-independent replacement reads `nodeType` through the cached
1495
- * Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
1496
- * constant (11). nodeType is a numeric value resolved from the node's
1497
- * internal slot, identical across realms for the same kind of node.
1498
- *
1499
- * @param value object to check
1500
- * @return true if value is a DocumentFragment-shaped node from any realm
1501
- */
1502
- const _isDocumentFragment = function _isDocumentFragment(value) {
1503
- if (!getNodeType || typeof value !== 'object' || value === null) {
1504
- return false;
1505
- }
1506
- try {
1507
- return getNodeType(value) === NODE_TYPE.documentFragment;
1508
- } catch (_) {
1509
- return false;
1510
- }
1511
- };
1512
- /**
1513
- * Checks whether the given object is a DOM node, including nodes that
1514
- * originate from a different window/realm (e.g. an iframe's
1515
- * contentDocument). The previous `value instanceof Node` check was
1516
- * realm-bound: nodes from a different window failed it, causing
1517
- * sanitize() to silently stringify them and reset IN_PLACE to false,
1518
- * returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
1519
- *
1520
- * @param value object to check whether it's a DOM node
1521
- * @return true if value is a DOM node from any realm
1522
- */
1523
- const _isNode = function _isNode(value) {
1524
- if (!getNodeType || typeof value !== 'object' || value === null) {
1525
- return false;
1526
- }
1527
- try {
1528
- return typeof getNodeType(value) === 'number';
1529
- } catch (_) {
1530
- return false;
1531
- }
1532
- };
1533
- function _executeHooks(hooks, currentNode, data) {
1534
- if (hooks.length === 0) {
1535
- return;
1536
- }
1537
- arrayForEach(hooks, hook => {
1538
- hook.call(DOMPurify, currentNode, data, CONFIG);
1539
- });
1540
- }
1541
- /**
1542
- * Structural-threat checks that condemn a node regardless of the
1543
- * allowlists: mXSS via namespace confusion, risky CSS construction,
1544
- * processing instructions, markup-bearing comments. Pure predicate;
1545
- * the caller removes. Check order is load-bearing.
1546
- *
1547
- * @param currentNode the node to inspect
1548
- * @param tagName the node's transformCaseFunc'd tag name
1549
- * @return true if the node must be removed
1550
- */
1551
- const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
1552
- /* Detect mXSS attempts abusing namespace confusion */
1553
- if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
1554
- return true;
1555
- }
1556
- /* Remove risky CSS construction leading to mXSS */
1557
- if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {
1558
- return true;
1559
- }
1560
- /* Remove any occurrence of processing instructions */
1561
- if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
1562
- return true;
1563
- }
1564
- /* Remove any kind of possibly harmful comments */
1565
- if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {
1566
- return true;
1567
- }
1568
- return false;
1569
- };
1570
- /**
1571
- * Handle a node whose tag is forbidden or not allowlisted: keep
1572
- * allowed custom elements (false return exits _sanitizeElements
1573
- * early - the namespace and fallback-tag removal checks are
1574
- * intentionally skipped for kept custom elements), else hoist
1575
- * content per KEEP_CONTENT and remove.
1576
- *
1577
- * A kept custom element is the ONLY case in which this function
1578
- * returns false, so the caller uses that return value to run the
1579
- * afterSanitizeElements hook on the kept element and keep the
1580
- * element-hook lifecycle consistent with normal allowlisted
1581
- * elements (GHSA-c2j3-45gr-mqc4).
1582
- *
1583
- * @param currentNode the disallowed node
1584
- * @param tagName the node's transformCaseFunc'd tag name
1585
- * @return true if the node was removed, false if kept
1586
- */
1587
- const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName) {
1588
- /* Check if we have a custom element to handle */
1589
- if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
1590
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
1591
- return false;
1592
- }
1593
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
1594
- return false;
1595
- }
1596
- }
1597
- /* Keep content except for bad-listed elements.
1598
- Use the cached prototype getters exclusively — the previous code
1599
- had `|| currentNode.parentNode` / `|| currentNode.childNodes`
1600
- fallbacks, but the cached getters always return the canonical
1601
- value (or null for a real parent-less node), so the fallback
1602
- path was dead in safe cases and a clobbering surface in unsafe
1603
- ones. Falsy cached results stay falsy; the `if (childNodes &&
1604
- parentNode)` check already gates correctly. */
1605
- if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
1606
- const parentNode = getParentNode(currentNode);
1607
- const childNodes = getChildNodes(currentNode);
1608
- if (childNodes && parentNode) {
1609
- const childCount = childNodes.length;
1610
- /* In-place: hoist the *original* children so the iterator visits
1611
- and sanitises them through the same allowlist pass as every other
1612
- node. The caller built the tree in the live document, so the
1613
- originals carry already-queued resource events (`<img onerror>`,
1614
- `<video>`/`<audio>` error, lazy/`onload`, …); cloning would leave
1615
- those originals detached but still armed, firing in page scope
1616
- while the returned tree looked clean. Moving is safe in-place: the
1617
- root is pre-validated as an allowed tag and so is never the node
1618
- being removed, which keeps `parentNode` inside the iterator root
1619
- and the relocated child inside the serialised tree.
1620
- Otherwise (string / DOM-copy paths): clone. The iterator is rooted
1621
- at — and the result serialised from — `body`, so a restrictive
1622
- ALLOWED_TAGS that removes `body` itself must leave its content in
1623
- place, which only cloning does; and those paths parse into an
1624
- inert document, so their discarded originals never had a queued
1625
- event to neutralise.
1626
- `childNodes` is live; a tail-to-head walk keeps `childNodes[i]`
1627
- valid whether we move (drops the trailing entry) or clone (leaves
1628
- the list intact). */
1629
- for (let i = childCount - 1; i >= 0; --i) {
1630
- const hoisted = IN_PLACE ? childNodes[i] : cloneNode(childNodes[i], true);
1631
- parentNode.insertBefore(hoisted, getNextSibling(currentNode));
1632
- }
1633
- }
1634
- }
1635
- _forceRemove(currentNode);
1636
- return true;
1637
- };
1638
- /**
1639
- * _sanitizeElements
1640
- *
1641
- * @protect nodeName
1642
- * @protect textContent
1643
- * @protect removeChild
1644
- * @param currentNode to check for permission to exist
1645
- * @return true if node was killed, false if left alive
1646
- */
1647
- // eslint-disable-next-line complexity
1648
- const _sanitizeElements = function _sanitizeElements(currentNode, root) {
1649
- /* Execute a hook if present */
1650
- _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
1651
- /* A hook may have detached the node — treat it as removed (see the
1652
- detached-node comment after the uponSanitizeElement hook below). */
1653
- if (currentNode !== root && getParentNode(currentNode) === null) {
1654
- return true;
1655
- }
1656
- /* Check if element is clobbered or can clobber */
1657
- if (_isClobbered(currentNode)) {
1658
- _forceRemove(currentNode);
1659
- return true;
1660
- }
1661
- /* Now let's check the element's type and name */
1662
- const tagName = transformCaseFunc(getNodeName ? getNodeName(currentNode) : currentNode.nodeName);
1663
- /* Execute a hook if present */
1664
- _executeHooks(hooks.uponSanitizeElement, currentNode, {
1665
- tagName,
1666
- allowedTags: ALLOWED_TAGS
1667
- });
1668
- /* A hook may have detached the node from the tree — a long-standing
1669
- user pattern (issue #469; draw.io-style foreignObject filtering).
1670
- Per the cached, unclobberable parentNode getter the node is
1671
- genuinely out of the tree, so it can reach neither the serialized
1672
- output nor an IN_PLACE live tree; treat it as removed and stop
1673
- processing it. Without this guard, the unsafe-node / namespace
1674
- checks below would call _forceRemove on a parentless node and hit
1675
- the REPORT-3 fail-closed throw — which exists for nodes DOMPurify
1676
- wants gone but *cannot* detach (clobbered / parentless roots), the
1677
- opposite of a node that is already safely gone. The walk root is
1678
- exempt: a detached IN_PLACE root is legitimate input and must still
1679
- be fully sanitized, and a kill-decision on it must keep hitting the
1680
- REPORT-3 throw. Nodes detached by hooks are the hook's
1681
- responsibility: they are not recorded in DOMPurify.removed and are
1682
- not neutralized by the post-walk IN_PLACE pass. */
1683
- if (currentNode !== root && getParentNode(currentNode) === null) {
1684
- return true;
1685
- }
1686
- /* Remove mXSS vectors, processing instructions and risky comments */
1687
- if (_isUnsafeNode(currentNode, tagName)) {
1688
- _forceRemove(currentNode);
1689
- return true;
1690
- }
1691
- /* Remove element if anything forbids its presence */
1692
- if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
1693
- const removed = _sanitizeDisallowedNode(currentNode, tagName);
1694
- /* A false return means the node is a custom element kept via
1695
- CUSTOM_ELEMENT_HANDLING - the only keep path through
1696
- _sanitizeDisallowedNode. Run afterSanitizeElements on it so the
1697
- element-hook lifecycle matches normal allowlisted elements: a
1698
- security policy applied in this hook (e.g. stripping an attribute
1699
- from every surviving element) must not silently skip kept custom
1700
- elements (GHSA-c2j3-45gr-mqc4). This mirrors the normal-element
1701
- tail below - the hook runs, then the walker's subsequent
1702
- _sanitizeAttributes pass sanitizes the element's attributes. The
1703
- deliberately skipped namespace and fallback-tag removal checks stay
1704
- skipped; they are removal decisions, not the hook contract. */
1705
- if (removed === false) {
1706
- _executeHooks(hooks.afterSanitizeElements, currentNode, null);
1707
- }
1708
- return removed;
1709
- }
1710
- /* Check whether element has a valid namespace.
1711
- Realm-safe check (GHSA-hpcv-96wg-7vj8): use the cached Node.prototype
1712
- nodeType getter rather than `instanceof Element`, which is realm-
1713
- bound and short-circuits to false for any node minted in a different
1714
- realm — letting a foreign-realm element with a forbidden namespace
1715
- slip past the namespace check entirely. */
1716
- const nt = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;
1717
- if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
1718
- _forceRemove(currentNode);
1719
- return true;
1720
- }
1721
- /* Make sure that older browsers don't get fallback-tag mXSS */
1722
- if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
1723
- _forceRemove(currentNode);
1724
- return true;
1725
- }
1726
- /* Sanitize element content to be template-safe */
1727
- if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
1728
- /* Get the element's text content */
1729
- const content = _stripTemplateExpressions(currentNode.textContent);
1730
- if (currentNode.textContent !== content) {
1731
- arrayPush(DOMPurify.removed, {
1732
- element: currentNode.cloneNode()
1733
- });
1734
- currentNode.textContent = content;
1735
- }
1736
- }
1737
- /* Execute a hook if present */
1738
- _executeHooks(hooks.afterSanitizeElements, currentNode, null);
1739
- return false;
1740
- };
1741
- /**
1742
- * _isValidAttribute
1743
- *
1744
- * @param lcTag Lowercase tag name of containing element.
1745
- * @param lcName Lowercase attribute name.
1746
- * @param value Attribute value.
1747
- * @return Returns true if `value` is valid, otherwise false.
1748
- */
1749
- // eslint-disable-next-line complexity
1750
- const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1751
- /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
1752
- if (FORBID_ATTR[lcName]) {
1753
- return false;
1754
- }
1755
- /* Reject declarative-partial-updates patch-linkage attributes
1756
- (https://github.com/WICG/declarative-partial-updates).
1757
- Empirical note (Chrome 150, verified — see
1758
- test/declarative-patch-probe-v3.html): expansion is NOT applied after
1759
- sanitization. For the string path it fires during sanitize()'s own
1760
- parse, so the walk sees and sanitizes the fully materialized expanded
1761
- tree — teleports into MathML/SVG integration points included; a
1762
- weaponized `<template for>`->`<img onerror>` comes back with the handler
1763
- stripped. For the IN_PLACE path it fires on connection, before the walk.
1764
- Either way DOMPurify is NOT blind to the patch.
1765
- This removal is therefore defense-in-depth rather than the sole barrier:
1766
- it prevents live linkage from surviving into the OUTPUT and re-expanding
1767
- in the caller's context, and keeps behaviour deterministic if a future
1768
- engine defers expansion. `for` is legitimate only on <label>/<output>;
1769
- anywhere else (notably <template for>) it links the element to a patch
1770
- target and teleports or removes an arbitrary DOM range by id/marker name.
1771
- `patchsrc` fetches remote markup and is treated as a script-loading
1772
- mechanism (CSP). Gated on SAFE_FOR_XML so the removal groups with the
1773
- other structural-threat checks and stays overridable, consistent with
1774
- the rest of the codebase. PI range markers are already removed by
1775
- _isUnsafeNode. */
1776
- if (SAFE_FOR_XML && lcName === 'patchsrc') {
1777
- return false;
1778
- }
1779
- if (SAFE_FOR_XML && lcName === 'for' && lcTag !== 'label' && lcTag !== 'output') {
1780
- return false;
1781
- }
1782
- /* Make sure attribute cannot clobber */
1783
- if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1784
- return false;
1785
- }
1786
- const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
1787
- /* Allow valid data-* attributes: At least one character after "-"
1788
- (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
1789
- XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
1790
- We don't need to check the value; it's always URI safe. */
1791
- if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ; else if (!nameIsPermitted) {
1792
- if (
1793
- // First condition does a very basic check if a) it's basically a valid custom element tagname AND
1794
- // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1795
- // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
1796
- _isBasicCustomElement(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, lcTag)) ||
1797
- // Alternative, second condition checks if it's an `is`-attribute, AND
1798
- // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1799
- 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 {
1800
- return false;
1801
- }
1802
- /* Check value is safe. First, is attr inert? If so, is safe */
1803
- } 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) {
1804
- return false;
1805
- } else ;
1806
- return true;
1807
- };
1808
- /* Names the HTML spec reserves from valid-custom-element-name; these must
1809
- * never be treated as basic custom elements even when a permissive
1810
- * CUSTOM_ELEMENT_HANDLING.tagNameCheck is configured. */
1811
- const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ['annotation-xml', 'color-profile', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'missing-glyph']);
1812
- /**
1813
- * _isBasicCustomElement
1814
- * checks if at least one dash is included in tagName, and it's not the first char
1815
- * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
1816
- *
1817
- * @param tagName name of the tag of the node to sanitize
1818
- * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
1819
- */
1820
- const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
1821
- return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
1822
- };
1823
- /**
1824
- * Wrap an attribute value in the matching Trusted Types object when
1825
- * the active policy requires it. Namespaced attributes pass through
1826
- * unchanged (no TT support yet, see
1827
- * https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).
1828
- *
1829
- * @param lcTag lowercase tag name of the containing element
1830
- * @param lcName lowercase attribute name
1831
- * @param namespaceURI the attribute's namespace, if any
1832
- * @param value the attribute value to wrap
1833
- * @return the value, wrapped when Trusted Types demand it
1834
- */
1835
- const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {
1836
- if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function' && !namespaceURI) {
1837
- switch (trustedTypes.getAttributeType(lcTag, lcName)) {
1838
- case 'TrustedHTML':
1839
- {
1840
- return _createTrustedHTML(value);
1841
- }
1842
- case 'TrustedScriptURL':
1843
- {
1844
- return _createTrustedScriptURL(value);
1845
- }
1846
- }
1847
- }
1848
- return value;
1849
- };
1850
- /**
1851
- * Write a modified attribute value back onto the element. On
1852
- * success, re-probe for clobbering introduced by the new value and
1853
- * remove the element when found; otherwise pop the removal entry
1854
- * recorded by the earlier _removeAttribute (long-standing pairing
1855
- * with the SANITIZE_NAMED_PROPS path - do not "fix" casually). On
1856
- * failure, remove the attribute instead.
1857
- *
1858
- * @param currentNode the element carrying the attribute
1859
- * @param name the attribute name as present on the element
1860
- * @param namespaceURI the attribute's namespace, if any
1861
- * @param value the new attribute value
1862
- */
1863
- const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
1864
- try {
1865
- if (namespaceURI) {
1866
- currentNode.setAttributeNS(namespaceURI, name, value);
1867
- } else {
1868
- /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
1869
- currentNode.setAttribute(name, value);
1870
- }
1871
- if (_isClobbered(currentNode)) {
1872
- _forceRemove(currentNode);
1873
- } else {
1874
- arrayPop(DOMPurify.removed);
1875
- }
1876
- } catch (_) {
1877
- _removeAttribute(name, currentNode);
1878
- }
1879
- };
1880
- /**
1881
- * _sanitizeAttributes
1882
- *
1883
- * @protect attributes
1884
- * @protect nodeName
1885
- * @protect removeAttribute
1886
- * @protect setAttribute
1887
- *
1888
- * @param currentNode to sanitize
1889
- */
1890
- const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
1891
- /* Execute a hook if present */
1892
- _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
1893
- const attributes = currentNode.attributes;
1894
- /* Check if we have attributes; if not we might have a text node */
1895
- if (!attributes || _isClobbered(currentNode)) {
1896
- return;
1897
- }
1898
- const hookEvent = {
1899
- attrName: '',
1900
- attrValue: '',
1901
- keepAttr: true,
1902
- allowedAttributes: ALLOWED_ATTR,
1903
- forceKeepAttr: undefined
1904
- };
1905
- let l = attributes.length;
1906
- const lcTag = transformCaseFunc(currentNode.nodeName);
1907
- /* Go backwards over all attributes; safely remove bad ones */
1908
- while (l--) {
1909
- const attr = attributes[l];
1910
- const name = attr.name,
1911
- namespaceURI = attr.namespaceURI,
1912
- attrValue = attr.value;
1913
- const lcName = transformCaseFunc(name);
1914
- const initValue = attrValue;
1915
- let value = name === 'value' ? initValue : stringTrim(initValue);
1916
- /* Execute a hook if present */
1917
- hookEvent.attrName = lcName;
1918
- hookEvent.attrValue = value;
1919
- hookEvent.keepAttr = true;
1920
- hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1921
- _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
1922
- value = hookEvent.attrValue;
1923
- /* Full DOM Clobbering protection via namespace isolation,
1924
- * Prefix id and name attributes with `user-content-`
1925
- */
1926
- if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name') && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
1927
- // Remove the attribute with this value
1928
- _removeAttribute(name, currentNode);
1929
- // Prefix the value and later re-create the attribute with the sanitized value
1930
- value = SANITIZE_NAMED_PROPS_PREFIX + value;
1931
- }
1932
- // Else: already prefixed, leave the attribute alone — the prefix is
1933
- // itself the clobbering protection, and re-applying it is incorrect.
1934
- /* Work around a security issue with comments inside attributes */
1935
- if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
1936
- _removeAttribute(name, currentNode);
1937
- continue;
1938
- }
1939
- /* Make sure we cannot easily use animated hrefs, even if animations are allowed */
1940
- if (lcName === 'attributename' && stringMatch(value, 'href')) {
1941
- _removeAttribute(name, currentNode);
1942
- continue;
1943
- }
1944
- /* Did the hooks force-keep the attribute? */
1945
- if (hookEvent.forceKeepAttr) {
1946
- continue;
1947
- }
1948
- /* Did the hooks approve of the attribute? */
1949
- if (!hookEvent.keepAttr) {
1950
- _removeAttribute(name, currentNode);
1951
- continue;
1952
- }
1953
- /* Work around a security issue in jQuery 3.0 */
1954
- if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
1955
- _removeAttribute(name, currentNode);
1956
- continue;
1957
- }
1958
- /* Sanitize attribute content to be template-safe */
1959
- if (SAFE_FOR_TEMPLATES) {
1960
- value = _stripTemplateExpressions(value);
1961
- }
1962
- /* Is `value` valid for this attribute? */
1963
- if (!_isValidAttribute(lcTag, lcName, value)) {
1964
- _removeAttribute(name, currentNode);
1965
- continue;
1966
- }
1967
- /* Handle attributes that require Trusted Types */
1968
- value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
1969
- /* Handle invalid data-* attribute set by try-catching it */
1970
- if (value !== initValue) {
1971
- _setAttributeValue(currentNode, name, namespaceURI, value);
1972
- }
1973
- }
1974
- /* Execute a hook if present */
1975
- _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
1976
- };
1977
- /**
1978
- * _sanitizeShadowDOM
1979
- *
1980
- * @param fragment to iterate over recursively
1981
- */
1982
- const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
1983
- let shadowNode = null;
1984
- const shadowIterator = _createNodeIterator(fragment);
1985
- /* Execute a hook if present */
1986
- _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
1987
- while (shadowNode = shadowIterator.nextNode()) {
1988
- /* Execute a hook if present */
1989
- _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
1990
- /* Sanitize tags and elements */
1991
- _sanitizeElements(shadowNode, fragment);
1992
- /* Check attributes next */
1993
- _sanitizeAttributes(shadowNode);
1994
- /* Deep shadow DOM detected.
1995
- Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType against the
1996
- DOCUMENT_FRAGMENT_NODE constant rather than instanceof, so we
1997
- recurse into <template>.content from foreign realms too. */
1998
- if (_isDocumentFragment(shadowNode.content)) {
1999
- _sanitizeShadowDOM2(shadowNode.content);
2000
- }
2001
- /* An element iterated here may itself host an attached
2002
- shadow root. The default NodeIterator does not enter shadow
2003
- trees, so a shadow root nested inside template.content was
2004
- previously reached by no walk at all (the pre-pass at
2005
- _sanitizeAttachedShadowRoots descends via childNodes, which
2006
- doesn't enter template.content; the template-content recursion
2007
- above iterates the content but never inspected shadowRoot).
2008
- Walk it explicitly. The nodeType guard avoids reading
2009
- shadowRoot off text / comment / CDATA / PI nodes that the
2010
- iterator also surfaces. */
2011
- const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;
2012
- if (shadowNodeType === NODE_TYPE.element) {
2013
- const innerSr = getShadowRoot(shadowNode);
2014
- if (_isDocumentFragment(innerSr)) {
2015
- _sanitizeAttachedShadowRoots(innerSr);
2016
- _sanitizeShadowDOM2(innerSr);
2017
- }
2018
- }
2019
- }
2020
- /* Execute a hook if present */
2021
- _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
2022
- };
2023
- /**
2024
- * _sanitizeAttachedShadowRoots
2025
- *
2026
- * Walks `root` and feeds every attached shadow root we encounter into
2027
- * the existing _sanitizeShadowDOM pipeline. The default node iterator
2028
- * does not descend into shadow trees, so nodes inside an attached
2029
- * shadow root would otherwise be skipped entirely.
2030
- *
2031
- * Two real input paths put attached shadow roots in front of us:
2032
- * 1. IN_PLACE on a DOM node that already has shadow roots attached.
2033
- * 2. DOM-node input where importNode(dirty, true) deep-clones the
2034
- * shadow root because it was created with `clonable: true`.
2035
- *
2036
- * This pass runs once, up front, so the main iteration loop (and the
2037
- * existing _sanitizeShadowDOM template-content recursion) stay
2038
- * untouched — string-input paths are not affected.
2039
- *
2040
- * @param root the subtree root to walk for attached shadow roots
2041
- */
2042
- const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
2043
- /* Iterative (explicit stack) rather than per-child recursion. DOM APIs
2044
- impose no depth cap, so an attacker-shaped tree (JSON/CRDT/editor data
2045
- built straight into the DOM — the IN_PLACE surface) deeper than the JS
2046
- call-stack budget would otherwise overflow native recursion here and
2047
- throw at the IN_PLACE entry pre-pass, before a single node is
2048
- sanitized, leaving the caller's live tree untouched (fail-open). See
2049
- campaign-3 F4. A heap stack keeps depth off the call stack.
2050
- Each work item is either a node to descend into, or a deferred
2051
- `_sanitizeShadowDOM` for an already-walked shadow root. The deferred
2052
- form preserves the original post-order discipline: a shadow root's
2053
- nested shadow roots are discovered before the outer shadow is
2054
- sanitized (which may remove hosts). Pushes are in reverse of the
2055
- desired processing order (LIFO): template content, then children, then
2056
- the shadow-sanitize, then the shadow walk — so the order matches the
2057
- previous recursion exactly. */
2058
- const stack = [{
2059
- node: root,
2060
- shadow: null
2061
- }];
2062
- while (stack.length > 0) {
2063
- const item = stack.pop();
2064
- /* Deferred shadow-DOM sanitisation: runs after its subtree was walked. */
2065
- if (item.shadow) {
2066
- _sanitizeShadowDOM2(item.shadow);
2067
- continue;
2068
- }
2069
- const node = item.node;
2070
- const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
2071
- const isElement = nodeType === NODE_TYPE.element;
2072
- /* (pushed last → processed first) Children, snapshotted in reverse so
2073
- the first child is processed first. Snapshotting matters because a
2074
- hook may detach siblings mid-walk. */
2075
- const childNodes = getChildNodes(node);
2076
- if (childNodes) {
2077
- for (let i = childNodes.length - 1; i >= 0; --i) {
2078
- stack.push({
2079
- node: childNodes[i],
2080
- shadow: null
2081
- });
2082
- }
2083
- }
2084
- /* (pushed before children → processed after them, matching the old
2085
- "template content last" order) When the node is a <template>,
2086
- descend into its content. */
2087
- if (isElement) {
2088
- const rootName = getNodeName ? getNodeName(node) : null;
2089
- if (typeof rootName === 'string' && transformCaseFunc(rootName) === 'template') {
2090
- const content = node.content;
2091
- if (_isDocumentFragment(content)) {
2092
- stack.push({
2093
- node: content,
2094
- shadow: null
2095
- });
2096
- }
2097
- }
2098
- }
2099
- /* Shadow root (processed first): walk its subtree, then sanitise it.
2100
- Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
2101
- rather than `instanceof DocumentFragment`, which is realm-bound and
2102
- silently skipped foreign-realm shadow roots (e.g.
2103
- iframe.contentDocument attachShadow). */
2104
- if (isElement) {
2105
- const sr = getShadowRoot(node);
2106
- if (_isDocumentFragment(sr)) {
2107
- /* Push the deferred sanitise first so it pops after the shadow
2108
- walk we push next, i.e. nested shadow roots are discovered
2109
- before this one is sanitised. */
2110
- stack.push({
2111
- node: null,
2112
- shadow: sr
2113
- }, {
2114
- node: sr,
2115
- shadow: null
2116
- });
2117
- }
2118
- }
2119
- }
2120
- };
2121
- // eslint-disable-next-line complexity
2122
- DOMPurify.sanitize = function (dirty) {
2123
- let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2124
- let body = null;
2125
- let importedNode = null;
2126
- let currentNode = null;
2127
- let returnNode = null;
2128
- /* Make sure we have a string to sanitize.
2129
- DO NOT return early, as this will return the wrong type if
2130
- the user has requested a DOM object rather than a string */
2131
- IS_EMPTY_INPUT = !dirty;
2132
- if (IS_EMPTY_INPUT) {
2133
- dirty = '<!-->';
2134
- }
2135
- /* Stringify, in case dirty is an object */
2136
- if (typeof dirty !== 'string' && !_isNode(dirty)) {
2137
- dirty = stringifyValue(dirty);
2138
- if (typeof dirty !== 'string') {
2139
- throw typeErrorCreate('dirty is not a string, aborting');
2140
- }
2141
- }
2142
- /* Return dirty HTML if DOMPurify cannot run */
2143
- if (!DOMPurify.isSupported) {
2144
- return dirty;
2145
- }
2146
- /* Assign config vars */
2147
- if (SET_CONFIG) {
2148
- /* Persistent setConfig() path: _parseConfig is skipped, so the sets are
2149
- * not re-derived per call. Restore them from the pristine bindings
2150
- * captured at setConfig() time so a previous call's hook clone (mutated
2151
- * below) does not carry over. */
2152
- ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
2153
- ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
2154
- } else {
2155
- _parseConfig(cfg);
2156
- }
2157
- /* Clone the hook-mutable allowlists before the walk whenever an
2158
- * uponSanitize* hook is registered. The hook event exposes ALLOWED_TAGS
2159
- * and ALLOWED_ATTR by reference (as allowedTags / allowedAttributes), so
2160
- * a hook that widens them would otherwise mutate the shared set
2161
- * permanently: across later calls and across every element. Cloning per
2162
- * walk keeps documented in-call widening working while scoping it to the
2163
- * call. A single guard for both config paths - the per-call path rebinds
2164
- * the sets in _parseConfig each call, the persistent path restores them
2165
- * from the captured bindings just above - so the two cannot diverge. */
2166
- if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
2167
- ALLOWED_TAGS = clone(ALLOWED_TAGS);
2168
- }
2169
- if (hooks.uponSanitizeAttribute.length > 0) {
2170
- ALLOWED_ATTR = clone(ALLOWED_ATTR);
2171
- }
2172
- /* Clean up removed elements */
2173
- DOMPurify.removed = [];
2174
- /* Resolve IN_PLACE for this call without mutating persistent config.
2175
- Writing the IN_PLACE closure variable here leaks under setConfig(),
2176
- where _parseConfig is skipped on later calls: a single string call would
2177
- disable in-place mode for every subsequent node call, returning a
2178
- sanitized copy while leaving the caller's node — which in-place callers
2179
- keep using and whose return value they ignore — unsanitized. REPORT-2. */
2180
- const inPlace = IN_PLACE && typeof dirty !== 'string' && _isNode(dirty);
2181
- if (inPlace) {
2182
- /* Declarative-partial-updates / streaming pre-pass: sever every patch
2183
- linkage across the live tree BEFORE the walk, so no patch can fire
2184
- mid-walk and inject into an already-processed region. Runs first, so
2185
- it also covers the forbidden/clobbered roots that throw below. */
2186
- _neutralizePatchLinkage(dirty);
2187
- /* Do some early pre-sanitization to avoid unsafe root nodes.
2188
- Read nodeName through the cached prototype getter — a clobbering
2189
- child named "nodeName" on the form root would otherwise shadow
2190
- the property and let this check skip the root-allowlist
2191
- validation entirely. */
2192
- const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
2193
- if (typeof nn === 'string') {
2194
- const tagName = transformCaseFunc(nn);
2195
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
2196
- /* Fail closed on a live root: neutralize handlers/children before
2197
- throwing, exactly as the mid-walk abort path does. */
2198
- _neutralizeRoot(dirty);
2199
- throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
2200
- }
2201
- }
2202
- /* Pre-flight the root through _isClobbered. The iterator-driven
2203
- removal path can not detach a parent-less root: _forceRemove
2204
- falls through to Element.prototype.remove(), which per spec
2205
- is a no-op on a node with no parent. A clobbered root would
2206
- then survive the main loop with its attributes uninspected,
2207
- because _sanitizeAttributes early-returns on _isClobbered. The
2208
- result would be an attacker-controlled form, complete with any
2209
- event-handler attributes the caller passed in, handed back to
2210
- the application unsanitized. Refuse to sanitize such a root
2211
- the same way we refuse a forbidden tag. GHSA-r47g-fvhr-h676. */
2212
- if (_isClobbered(dirty)) {
2213
- /* Fail closed on a live clobbered root before throwing.
2214
- _neutralizeRoot's reads are clobber-safe (cached getters); the
2215
- form's non-clobbered descendants, e.g. an armed <img>, are scrubbed. */
2216
- _neutralizeRoot(dirty);
2217
- throw typeErrorCreate('root node is clobbered and cannot be sanitized in-place');
2218
- }
2219
- /* Sanitize attached shadow roots before the main iterator runs.
2220
- The iterator does not descend into shadow trees. Same fail-closed
2221
- barrier as the main walk (campaign-3 F2): a custom-element reaction
2222
- inside a shadow root could abort this pre-pass before the walk runs,
2223
- which would otherwise leave the entire live tree unsanitized. */
2224
- try {
2225
- _sanitizeAttachedShadowRoots(dirty);
2226
- } catch (error) {
2227
- _neutralizeRoot(dirty);
2228
- throw error;
2229
- }
2230
- } else if (_isNode(dirty)) {
2231
- /* If dirty is a DOM element, append to an empty document to avoid
2232
- elements being stripped by the parser */
2233
- body = _initDocument('<!---->');
2234
- importedNode = body.ownerDocument.importNode(dirty, true);
2235
- if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
2236
- /* Node is already a body, use as is */
2237
- body = importedNode;
2238
- } else if (importedNode.nodeName === 'HTML') {
2239
- body = importedNode;
2240
- } else {
2241
- // eslint-disable-next-line unicorn/prefer-dom-node-append
2242
- body.appendChild(importedNode);
2243
- }
2244
- /* Clonable shadow roots are deep-cloned by importNode(); sanitize
2245
- them before the main iterator runs, since the iterator does not
2246
- descend into shadow trees. The walk routes every read through a
2247
- cached prototype getter so clobbering descendants on a form root
2248
- cannot hide a shadow host from this pass. */
2249
- _sanitizeAttachedShadowRoots(importedNode);
2250
- } else {
2251
- /* Exit directly if we have nothing to do */
2252
- if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
2253
- // eslint-disable-next-line unicorn/prefer-includes
2254
- dirty.indexOf('<') === -1) {
2255
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
2256
- }
2257
- /* Initialize the document to work on */
2258
- body = _initDocument(dirty);
2259
- /* Check we have a DOM node from the data */
2260
- if (!body) {
2261
- return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
2262
- }
2263
- }
2264
- /* Remove first element node (ours) if FORCE_BODY is set */
2265
- if (body && FORCE_BODY) {
2266
- _forceRemove(body.firstChild);
2267
- }
2268
- /* Get node iterator */
2269
- const walkRoot = inPlace ? dirty : body;
2270
- const nodeIterator = _createNodeIterator(walkRoot);
2271
- /* Now start iterating over the created document.
2272
- The walk runs inside an exception barrier (campaign-3 F2): a re-entrant
2273
- engine/custom-element mutation can detach a node mid-walk so
2274
- `_forceRemove`'s parentless guard throws, aborting the loop. Without the
2275
- barrier the caller's in-place tree would be left half-sanitized with the
2276
- unvisited tail still armed. On any throw we fail closed — strip the
2277
- in-place root bare — then rethrow so the existing throw contract is
2278
- preserved. (String/DOM-copy paths never return the partial body, so the
2279
- propagating throw is already fail-closed there.) */
2280
- try {
2281
- while (currentNode = nodeIterator.nextNode()) {
2282
- /* Sanitize tags and elements */
2283
- _sanitizeElements(currentNode, walkRoot);
2284
- /* Check attributes next */
2285
- _sanitizeAttributes(currentNode);
2286
- /* Shadow DOM detected, sanitize it.
2287
- Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
2288
- instead of instanceof, so foreign-realm <template>.content is
2289
- walked correctly. */
2290
- if (_isDocumentFragment(currentNode.content)) {
2291
- _sanitizeShadowDOM2(currentNode.content);
2292
- }
2293
- }
2294
- } catch (error) {
2295
- if (inPlace) {
2296
- _neutralizeRoot(dirty);
2297
- /* Nodes _forceRemove'd earlier in the aborted walk are already
2298
- detached from the root, so _neutralizeRoot's subtree pass does not
2299
- reach them. Defuse them too, mirroring the success-path loop below. */
2300
- arrayForEach(DOMPurify.removed, entry => {
2301
- if (entry.element) {
2302
- _neutralizeSubtree(entry.element);
2303
- }
2304
- });
2305
- }
2306
- throw error;
2307
- }
2308
- /* If we sanitized `dirty` in-place, return it. */
2309
- if (inPlace) {
2310
- /* Fail-closed completion of the audit-5 F1 fix: every node removed from
2311
- the caller's live tree is detached but may still hold a queued
2312
- resource-event handler that fires in page scope after we return. The
2313
- move-hoist covers only disallowed-tag KEEP_CONTENT removals; strip the
2314
- non-allow-listed attributes off every other removed subtree (clobber,
2315
- mXSS, namespace, comments, KEEP_CONTENT:false, …) so those handlers are
2316
- cancelled before any event can fire. Runs synchronously, pre-return. */
2317
- arrayForEach(DOMPurify.removed, entry => {
2318
- if (entry.element) {
2319
- _neutralizeSubtree(entry.element);
2320
- }
2321
- });
2322
- if (SAFE_FOR_TEMPLATES) {
2323
- _scrubTemplateExpressions2(dirty);
2324
- }
2325
- return dirty;
2326
- }
2327
- /* Return sanitized string or DOM */
2328
- if (RETURN_DOM) {
2329
- if (SAFE_FOR_TEMPLATES) {
2330
- _scrubTemplateExpressions2(body);
2331
- }
2332
- if (RETURN_DOM_FRAGMENT) {
2333
- returnNode = createDocumentFragment.call(body.ownerDocument);
2334
- while (body.firstChild) {
2335
- // eslint-disable-next-line unicorn/prefer-dom-node-append
2336
- returnNode.appendChild(body.firstChild);
2337
- }
2338
- } else {
2339
- returnNode = body;
2340
- }
2341
- if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
2342
- /*
2343
- AdoptNode() is not used because internal state is not reset
2344
- (e.g. the past names map of a HTMLFormElement), this is safe
2345
- in theory but we would rather not risk another attack vector.
2346
- The state that is cloned by importNode() is explicitly defined
2347
- by the specs.
2348
- */
2349
- returnNode = importNode.call(originalDocument, returnNode, true);
2350
- }
2351
- return returnNode;
2352
- }
2353
- let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
2354
- /* Serialize doctype if allowed */
2355
- if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
2356
- serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
2357
- }
2358
- /* Sanitize final string template-safe */
2359
- if (SAFE_FOR_TEMPLATES) {
2360
- serializedHTML = _stripTemplateExpressions(serializedHTML);
2361
- }
2362
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
2363
- };
2364
- DOMPurify.setConfig = function () {
2365
- let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2366
- _parseConfig(cfg);
2367
- SET_CONFIG = true;
2368
- SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
2369
- SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
2370
- };
2371
- DOMPurify.clearConfig = function () {
2372
- CONFIG = null;
2373
- SET_CONFIG = false;
2374
- SET_CONFIG_ALLOWED_TAGS = null;
2375
- SET_CONFIG_ALLOWED_ATTR = null;
2376
- // Drop any caller-supplied Trusted Types policy so it cannot poison later
2377
- // `RETURN_TRUSTED_TYPE` output. The internal default policy (cached, and
2378
- // never recreated — Trusted Types throws on duplicate names) is restored by
2379
- // the next `_parseConfig`. See GHSA-vxr8-fq34-vvx9.
2380
- trustedTypesPolicy = defaultTrustedTypesPolicy;
2381
- emptyHTML = '';
2382
- };
2383
- DOMPurify.isValidAttribute = function (tag, attr, value) {
2384
- /* Initialize shared config vars if necessary. */
2385
- if (!CONFIG) {
2386
- _parseConfig({});
2387
- }
2388
- const lcTag = transformCaseFunc(tag);
2389
- const lcName = transformCaseFunc(attr);
2390
- return _isValidAttribute(lcTag, lcName, value);
2391
- };
2392
- DOMPurify.addHook = function (entryPoint, hookFunction) {
2393
- if (typeof hookFunction !== 'function') {
2394
- return;
2395
- }
2396
- /* Reject unknown entry points. Without this, a non-hook key (e.g.
2397
- * '__proto__') indexes off the prototype chain rather than a real
2398
- * hook array, and arrayPush then writes to Object.prototype. Guard
2399
- * with an own-property check against the known hook names. */
2400
- if (!objectHasOwnProperty(hooks, entryPoint)) {
2401
- return;
2402
- }
2403
- arrayPush(hooks[entryPoint], hookFunction);
2404
- };
2405
- DOMPurify.removeHook = function (entryPoint, hookFunction) {
2406
- if (!objectHasOwnProperty(hooks, entryPoint)) {
2407
- return undefined;
2408
- }
2409
- if (hookFunction !== undefined) {
2410
- const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
2411
- return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
2412
- }
2413
- return arrayPop(hooks[entryPoint]);
2414
- };
2415
- DOMPurify.removeHooks = function (entryPoint) {
2416
- if (!objectHasOwnProperty(hooks, entryPoint)) {
2417
- return;
2418
- }
2419
- hooks[entryPoint] = [];
2420
- };
2421
- DOMPurify.removeAllHooks = function () {
2422
- hooks = _createHooksMap();
2423
- };
2424
- return DOMPurify;
2425
- }
2426
- var purify = createDOMPurify();
2427
-
2428
- exports.default = purify;
2429
- //# sourceMappingURL=purify.es.js.map