dompurify 3.4.0 → 3.4.2

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.
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "scripts": {
3
+ "prepare": "husky",
3
4
  "lint": "xo src/*.ts",
4
5
  "format": "npm run format:js && npm run format:md",
5
6
  "format:md": "prettier --write --parser markdown '**/*.md'",
6
7
  "format:js": "prettier --write '{src,demos,scripts,test,website}/*.{js,ts}'",
7
8
  "commit-amend-build": "scripts/commit-amend-build.sh",
8
- "prebuild": "rimraf dist/**",
9
+ "prebuild": "rimraf dist",
9
10
  "dev": "cross-env NODE_ENV=development BABEL_ENV=rollup rollup -w -c -o dist/purify.js",
10
11
  "build": "npm run build:types && npm run build:rollup && npm run build:fix-types && npm run build:cleanup",
11
12
  "build:types": "tsc --outDir dist/types --declaration --emitDeclarationOnly",
@@ -16,10 +17,12 @@
16
17
  "build:es": "rollup -c -f es -o dist/purify.es.mjs",
17
18
  "build:cjs": "rollup -c -f cjs -o dist/purify.cjs.js",
18
19
  "build:cleanup": "rimraf dist/types",
20
+ "test": "cross-env NODE_ENV=test BABEL_ENV=rollup npm run lint && npm run test:jsdom && npm run test:browser -- --project=chromium",
19
21
  "test:jsdom": "cross-env NODE_ENV=test BABEL_ENV=rollup node test/jsdom-node-runner --dot",
20
- "test:karma": "cross-env NODE_ENV=test BABEL_ENV=rollup karma start test/karma.conf.js --log-level warn ",
21
- "test:ci": "cross-env NODE_ENV=test BABEL_ENV=rollup npm run test:jsdom && npm run test:karma -- --log-level error --reporters dots --single-run --shouldTestOnBrowserStack=\"${TEST_BROWSERSTACK}\" --shouldProbeOnly=\"${TEST_PROBE_ONLY}\"",
22
- "test": "cross-env NODE_ENV=test BABEL_ENV=rollup npm run lint && npm run test:jsdom && npm run test:karma -- --browsers Chrome",
22
+ "test:browser": "playwright test",
23
+ "test:browser:install": "playwright install",
24
+ "test:ci": "cross-env NODE_ENV=test BABEL_ENV=rollup npm run test:jsdom && npm run test:browser",
25
+ "test:fuzz": "cross-env NODE_ENV=test BABEL_ENV=rollup node test/fuzz/sanitize.fast-check.js",
23
26
  "verify-typescript": "node ./typescript/verify.js"
24
27
  },
25
28
  "main": "./dist/purify.cjs.js",
@@ -44,12 +47,8 @@
44
47
  "./dist/purify.js": "./dist/purify.js"
45
48
  },
46
49
  "files": [
47
- "dist"
48
- ],
49
- "pre-commit": [
50
- "lint",
51
- "build",
52
- "commit-amend-build"
50
+ "dist",
51
+ "src"
53
52
  ],
54
53
  "xo": {
55
54
  "semicolon": true,
@@ -110,33 +109,27 @@
110
109
  "devDependencies": {
111
110
  "@babel/core": "^7.17.8",
112
111
  "@babel/preset-env": "^7.29.2",
113
- "@rollup/plugin-babel": "^6.0.4",
112
+ "@playwright/test": "^1.49.0",
113
+ "@rollup/plugin-babel": "^7.0.0",
114
114
  "@rollup/plugin-node-resolve": "^16.0.3",
115
115
  "@rollup/plugin-replace": "^6.0.1",
116
116
  "@rollup/plugin-terser": "^1.0.0",
117
+ "@rollup/plugin-typescript": "^12.3.0",
117
118
  "@types/estree": "^1.0.0",
118
- "@types/node": "^16.18.120",
119
+ "@types/node": "^25.6.0",
119
120
  "cross-env": "^10.1.0",
120
121
  "eslint-config-prettier": "^10.1.8",
121
- "eslint-plugin-prettier": "^4.0.0",
122
+ "eslint-plugin-prettier": "^5.2.1",
123
+ "fast-check": "^4.7.0",
124
+ "husky": "^9.1.0",
122
125
  "jquery": "^3.6.0",
123
- "jsdom": "^29.0.2",
124
- "karma": "^6.3.17",
125
- "karma-browserstack-launcher": "^1.5.1",
126
- "karma-chrome-launcher": "^3.1.0",
127
- "karma-firefox-launcher": "^2.1.2",
128
- "karma-qunit": "^4.1.2",
129
- "karma-rollup-preprocessor": "^7.0.8",
130
- "minimist": "^1.2.6",
131
- "pre-commit": "^1.2.2",
132
- "prettier": "^2.5.1",
126
+ "jsdom": "^29.1.0",
127
+ "prettier": "^3.3.3",
133
128
  "qunit": "^2.4.1",
134
129
  "qunit-tap": "^1.5.0",
135
- "rimraf": "^3.0.2",
136
- "rollup": "^4.60.1",
130
+ "rimraf": "^6.0.1",
131
+ "rollup": "^4.60.2",
137
132
  "rollup-plugin-dts": "^6.4.1",
138
- "rollup-plugin-includepaths": "^0.2.4",
139
- "rollup-plugin-typescript2": "^0.36.0",
140
133
  "tslib": "^2.7.0",
141
134
  "typescript": "^5.6.3",
142
135
  "xo": "^0.54.1"
@@ -146,7 +139,7 @@
146
139
  },
147
140
  "name": "dompurify",
148
141
  "description": "DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. It's written in JavaScript and works in all modern browsers (Safari, Opera (15+), Internet Explorer (10+), Firefox and Chrome - as well as almost anything else using Blink or WebKit). DOMPurify is written by security people who have vast background in web attacks and XSS. Fear not.",
149
- "version": "3.4.0",
142
+ "version": "3.4.2",
150
143
  "directories": {
151
144
  "test": "test"
152
145
  },
package/src/attrs.ts ADDED
@@ -0,0 +1,376 @@
1
+ import { freeze } from './utils.js';
2
+
3
+ export const html = freeze([
4
+ 'accept',
5
+ 'action',
6
+ 'align',
7
+ 'alt',
8
+ 'autocapitalize',
9
+ 'autocomplete',
10
+ 'autopictureinpicture',
11
+ 'autoplay',
12
+ 'background',
13
+ 'bgcolor',
14
+ 'border',
15
+ 'capture',
16
+ 'cellpadding',
17
+ 'cellspacing',
18
+ 'checked',
19
+ 'cite',
20
+ 'class',
21
+ 'clear',
22
+ 'color',
23
+ 'cols',
24
+ 'colspan',
25
+ 'controls',
26
+ 'controlslist',
27
+ 'coords',
28
+ 'crossorigin',
29
+ 'datetime',
30
+ 'decoding',
31
+ 'default',
32
+ 'dir',
33
+ 'disabled',
34
+ 'disablepictureinpicture',
35
+ 'disableremoteplayback',
36
+ 'download',
37
+ 'draggable',
38
+ 'enctype',
39
+ 'enterkeyhint',
40
+ 'exportparts',
41
+ 'face',
42
+ 'for',
43
+ 'headers',
44
+ 'height',
45
+ 'hidden',
46
+ 'high',
47
+ 'href',
48
+ 'hreflang',
49
+ 'id',
50
+ 'inert',
51
+ 'inputmode',
52
+ 'integrity',
53
+ 'ismap',
54
+ 'kind',
55
+ 'label',
56
+ 'lang',
57
+ 'list',
58
+ 'loading',
59
+ 'loop',
60
+ 'low',
61
+ 'max',
62
+ 'maxlength',
63
+ 'media',
64
+ 'method',
65
+ 'min',
66
+ 'minlength',
67
+ 'multiple',
68
+ 'muted',
69
+ 'name',
70
+ 'nonce',
71
+ 'noshade',
72
+ 'novalidate',
73
+ 'nowrap',
74
+ 'open',
75
+ 'optimum',
76
+ 'part',
77
+ 'pattern',
78
+ 'placeholder',
79
+ 'playsinline',
80
+ 'popover',
81
+ 'popovertarget',
82
+ 'popovertargetaction',
83
+ 'poster',
84
+ 'preload',
85
+ 'pubdate',
86
+ 'radiogroup',
87
+ 'readonly',
88
+ 'rel',
89
+ 'required',
90
+ 'rev',
91
+ 'reversed',
92
+ 'role',
93
+ 'rows',
94
+ 'rowspan',
95
+ 'spellcheck',
96
+ 'scope',
97
+ 'selected',
98
+ 'shape',
99
+ 'size',
100
+ 'sizes',
101
+ 'slot',
102
+ 'span',
103
+ 'srclang',
104
+ 'start',
105
+ 'src',
106
+ 'srcset',
107
+ 'step',
108
+ 'style',
109
+ 'summary',
110
+ 'tabindex',
111
+ 'title',
112
+ 'translate',
113
+ 'type',
114
+ 'usemap',
115
+ 'valign',
116
+ 'value',
117
+ 'width',
118
+ 'wrap',
119
+ 'xmlns',
120
+ ] as const);
121
+
122
+ export const svg = freeze([
123
+ 'accent-height',
124
+ 'accumulate',
125
+ 'additive',
126
+ 'alignment-baseline',
127
+ 'amplitude',
128
+ 'ascent',
129
+ 'attributename',
130
+ 'attributetype',
131
+ 'azimuth',
132
+ 'basefrequency',
133
+ 'baseline-shift',
134
+ 'begin',
135
+ 'bias',
136
+ 'by',
137
+ 'class',
138
+ 'clip',
139
+ 'clippathunits',
140
+ 'clip-path',
141
+ 'clip-rule',
142
+ 'color',
143
+ 'color-interpolation',
144
+ 'color-interpolation-filters',
145
+ 'color-profile',
146
+ 'color-rendering',
147
+ 'cx',
148
+ 'cy',
149
+ 'd',
150
+ 'dx',
151
+ 'dy',
152
+ 'diffuseconstant',
153
+ 'direction',
154
+ 'display',
155
+ 'divisor',
156
+ 'dur',
157
+ 'edgemode',
158
+ 'elevation',
159
+ 'end',
160
+ 'exponent',
161
+ 'fill',
162
+ 'fill-opacity',
163
+ 'fill-rule',
164
+ 'filter',
165
+ 'filterunits',
166
+ 'flood-color',
167
+ 'flood-opacity',
168
+ 'font-family',
169
+ 'font-size',
170
+ 'font-size-adjust',
171
+ 'font-stretch',
172
+ 'font-style',
173
+ 'font-variant',
174
+ 'font-weight',
175
+ 'fx',
176
+ 'fy',
177
+ 'g1',
178
+ 'g2',
179
+ 'glyph-name',
180
+ 'glyphref',
181
+ 'gradientunits',
182
+ 'gradienttransform',
183
+ 'height',
184
+ 'href',
185
+ 'id',
186
+ 'image-rendering',
187
+ 'in',
188
+ 'in2',
189
+ 'intercept',
190
+ 'k',
191
+ 'k1',
192
+ 'k2',
193
+ 'k3',
194
+ 'k4',
195
+ 'kerning',
196
+ 'keypoints',
197
+ 'keysplines',
198
+ 'keytimes',
199
+ 'lang',
200
+ 'lengthadjust',
201
+ 'letter-spacing',
202
+ 'kernelmatrix',
203
+ 'kernelunitlength',
204
+ 'lighting-color',
205
+ 'local',
206
+ 'marker-end',
207
+ 'marker-mid',
208
+ 'marker-start',
209
+ 'markerheight',
210
+ 'markerunits',
211
+ 'markerwidth',
212
+ 'maskcontentunits',
213
+ 'maskunits',
214
+ 'max',
215
+ 'mask',
216
+ 'mask-type',
217
+ 'media',
218
+ 'method',
219
+ 'mode',
220
+ 'min',
221
+ 'name',
222
+ 'numoctaves',
223
+ 'offset',
224
+ 'operator',
225
+ 'opacity',
226
+ 'order',
227
+ 'orient',
228
+ 'orientation',
229
+ 'origin',
230
+ 'overflow',
231
+ 'paint-order',
232
+ 'path',
233
+ 'pathlength',
234
+ 'patterncontentunits',
235
+ 'patterntransform',
236
+ 'patternunits',
237
+ 'points',
238
+ 'preservealpha',
239
+ 'preserveaspectratio',
240
+ 'primitiveunits',
241
+ 'r',
242
+ 'rx',
243
+ 'ry',
244
+ 'radius',
245
+ 'refx',
246
+ 'refy',
247
+ 'repeatcount',
248
+ 'repeatdur',
249
+ 'restart',
250
+ 'result',
251
+ 'rotate',
252
+ 'scale',
253
+ 'seed',
254
+ 'shape-rendering',
255
+ 'slope',
256
+ 'specularconstant',
257
+ 'specularexponent',
258
+ 'spreadmethod',
259
+ 'startoffset',
260
+ 'stddeviation',
261
+ 'stitchtiles',
262
+ 'stop-color',
263
+ 'stop-opacity',
264
+ 'stroke-dasharray',
265
+ 'stroke-dashoffset',
266
+ 'stroke-linecap',
267
+ 'stroke-linejoin',
268
+ 'stroke-miterlimit',
269
+ 'stroke-opacity',
270
+ 'stroke',
271
+ 'stroke-width',
272
+ 'style',
273
+ 'surfacescale',
274
+ 'systemlanguage',
275
+ 'tabindex',
276
+ 'tablevalues',
277
+ 'targetx',
278
+ 'targety',
279
+ 'transform',
280
+ 'transform-origin',
281
+ 'text-anchor',
282
+ 'text-decoration',
283
+ 'text-rendering',
284
+ 'textlength',
285
+ 'type',
286
+ 'u1',
287
+ 'u2',
288
+ 'unicode',
289
+ 'values',
290
+ 'viewbox',
291
+ 'visibility',
292
+ 'version',
293
+ 'vert-adv-y',
294
+ 'vert-origin-x',
295
+ 'vert-origin-y',
296
+ 'width',
297
+ 'word-spacing',
298
+ 'wrap',
299
+ 'writing-mode',
300
+ 'xchannelselector',
301
+ 'ychannelselector',
302
+ 'x',
303
+ 'x1',
304
+ 'x2',
305
+ 'xmlns',
306
+ 'y',
307
+ 'y1',
308
+ 'y2',
309
+ 'z',
310
+ 'zoomandpan',
311
+ ] as const);
312
+
313
+ export const mathMl = freeze([
314
+ 'accent',
315
+ 'accentunder',
316
+ 'align',
317
+ 'bevelled',
318
+ 'close',
319
+ 'columnalign',
320
+ 'columnlines',
321
+ 'columnspacing',
322
+ 'columnspan',
323
+ 'denomalign',
324
+ 'depth',
325
+ 'dir',
326
+ 'display',
327
+ 'displaystyle',
328
+ 'encoding',
329
+ 'fence',
330
+ 'frame',
331
+ 'height',
332
+ 'href',
333
+ 'id',
334
+ 'largeop',
335
+ 'length',
336
+ 'linethickness',
337
+ 'lquote',
338
+ 'lspace',
339
+ 'mathbackground',
340
+ 'mathcolor',
341
+ 'mathsize',
342
+ 'mathvariant',
343
+ 'maxsize',
344
+ 'minsize',
345
+ 'movablelimits',
346
+ 'notation',
347
+ 'numalign',
348
+ 'open',
349
+ 'rowalign',
350
+ 'rowlines',
351
+ 'rowspacing',
352
+ 'rowspan',
353
+ 'rspace',
354
+ 'rquote',
355
+ 'scriptlevel',
356
+ 'scriptminsize',
357
+ 'scriptsizemultiplier',
358
+ 'selection',
359
+ 'separator',
360
+ 'separators',
361
+ 'stretchy',
362
+ 'subscriptshift',
363
+ 'supscriptshift',
364
+ 'symmetric',
365
+ 'voffset',
366
+ 'width',
367
+ 'xmlns',
368
+ ]);
369
+
370
+ export const xml = freeze([
371
+ 'xlink:href',
372
+ 'xml:id',
373
+ 'xlink:title',
374
+ 'xml:space',
375
+ 'xmlns:xlink',
376
+ ] as const);