dompurify 3.4.3 → 3.4.5
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/LICENSE +1 -367
- package/README.md +5 -5
- package/dist/purify.cjs.d.ts +1 -1
- package/dist/purify.cjs.js +64 -13
- package/dist/purify.cjs.js.map +1 -1
- package/dist/purify.es.d.mts +1 -1
- package/dist/purify.es.mjs +64 -13
- package/dist/purify.es.mjs.map +1 -1
- package/dist/purify.js +64 -13
- package/dist/purify.js.map +1 -1
- package/dist/purify.min.js +2 -2
- package/dist/purify.min.js.map +1 -1
- package/package.json +3 -3
- package/src/attrs.ts +2 -0
- package/src/purify.ts +73 -10
package/LICENSE
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
DOMPurify
|
|
2
|
-
Copyright 2025-2026 Dr.-Ing. Mario Heiderich, Cure53
|
|
3
|
-
|
|
4
|
-
DOMPurify is free software; you can redistribute it and/or modify it under the
|
|
5
|
-
terms of either:
|
|
6
|
-
|
|
7
|
-
a) the Apache License Version 2.0, or
|
|
8
|
-
b) the Mozilla Public License Version 2.0
|
|
9
|
-
|
|
10
|
-
-----------------------------------------------------------------------------
|
|
11
1
|
|
|
12
2
|
Apache License
|
|
13
3
|
Version 2.0, January 2004
|
|
@@ -197,7 +187,7 @@ b) the Mozilla Public License Version 2.0
|
|
|
197
187
|
same "printed page" as the copyright notice for easier
|
|
198
188
|
identification within third-party archives.
|
|
199
189
|
|
|
200
|
-
Copyright
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
201
191
|
|
|
202
192
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
203
193
|
you may not use this file except in compliance with the License.
|
|
@@ -210,359 +200,3 @@ Copyright 2025-2026 Dr.-Ing. Mario Heiderich, Cure53
|
|
|
210
200
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
211
201
|
See the License for the specific language governing permissions and
|
|
212
202
|
limitations under the License.
|
|
213
|
-
|
|
214
|
-
-----------------------------------------------------------------------------
|
|
215
|
-
Mozilla Public License, version 2.0
|
|
216
|
-
|
|
217
|
-
1. Definitions
|
|
218
|
-
|
|
219
|
-
1.1. “Contributor”
|
|
220
|
-
|
|
221
|
-
means each individual or legal entity that creates, contributes to the
|
|
222
|
-
creation of, or owns Covered Software.
|
|
223
|
-
|
|
224
|
-
1.2. “Contributor Version”
|
|
225
|
-
|
|
226
|
-
means the combination of the Contributions of others (if any) used by a
|
|
227
|
-
Contributor and that particular Contributor’s Contribution.
|
|
228
|
-
|
|
229
|
-
1.3. “Contribution”
|
|
230
|
-
|
|
231
|
-
means Covered Software of a particular Contributor.
|
|
232
|
-
|
|
233
|
-
1.4. “Covered Software”
|
|
234
|
-
|
|
235
|
-
means Source Code Form to which the initial Contributor has attached the
|
|
236
|
-
notice in Exhibit A, the Executable Form of such Source Code Form, and
|
|
237
|
-
Modifications of such Source Code Form, in each case including portions
|
|
238
|
-
thereof.
|
|
239
|
-
|
|
240
|
-
1.5. “Incompatible With Secondary Licenses”
|
|
241
|
-
means
|
|
242
|
-
|
|
243
|
-
a. that the initial Contributor has attached the notice described in
|
|
244
|
-
Exhibit B to the Covered Software; or
|
|
245
|
-
|
|
246
|
-
b. that the Covered Software was made available under the terms of version
|
|
247
|
-
1.1 or earlier of the License, but not also under the terms of a
|
|
248
|
-
Secondary License.
|
|
249
|
-
|
|
250
|
-
1.6. “Executable Form”
|
|
251
|
-
|
|
252
|
-
means any form of the work other than Source Code Form.
|
|
253
|
-
|
|
254
|
-
1.7. “Larger Work”
|
|
255
|
-
|
|
256
|
-
means a work that combines Covered Software with other material, in a separate
|
|
257
|
-
file or files, that is not Covered Software.
|
|
258
|
-
|
|
259
|
-
1.8. “License”
|
|
260
|
-
|
|
261
|
-
means this document.
|
|
262
|
-
|
|
263
|
-
1.9. “Licensable”
|
|
264
|
-
|
|
265
|
-
means having the right to grant, to the maximum extent possible, whether at the
|
|
266
|
-
time of the initial grant or subsequently, any and all of the rights conveyed by
|
|
267
|
-
this License.
|
|
268
|
-
|
|
269
|
-
1.10. “Modifications”
|
|
270
|
-
|
|
271
|
-
means any of the following:
|
|
272
|
-
|
|
273
|
-
a. any file in Source Code Form that results from an addition to, deletion
|
|
274
|
-
from, or modification of the contents of Covered Software; or
|
|
275
|
-
|
|
276
|
-
b. any new file in Source Code Form that contains any Covered Software.
|
|
277
|
-
|
|
278
|
-
1.11. “Patent Claims” of a Contributor
|
|
279
|
-
|
|
280
|
-
means any patent claim(s), including without limitation, method, process,
|
|
281
|
-
and apparatus claims, in any patent Licensable by such Contributor that
|
|
282
|
-
would be infringed, but for the grant of the License, by the making,
|
|
283
|
-
using, selling, offering for sale, having made, import, or transfer of
|
|
284
|
-
either its Contributions or its Contributor Version.
|
|
285
|
-
|
|
286
|
-
1.12. “Secondary License”
|
|
287
|
-
|
|
288
|
-
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
|
289
|
-
General Public License, Version 2.1, the GNU Affero General Public
|
|
290
|
-
License, Version 3.0, or any later versions of those licenses.
|
|
291
|
-
|
|
292
|
-
1.13. “Source Code Form”
|
|
293
|
-
|
|
294
|
-
means the form of the work preferred for making modifications.
|
|
295
|
-
|
|
296
|
-
1.14. “You” (or “Your”)
|
|
297
|
-
|
|
298
|
-
means an individual or a legal entity exercising rights under this
|
|
299
|
-
License. For legal entities, “You” includes any entity that controls, is
|
|
300
|
-
controlled by, or is under common control with You. For purposes of this
|
|
301
|
-
definition, “control” means (a) the power, direct or indirect, to cause
|
|
302
|
-
the direction or management of such entity, whether by contract or
|
|
303
|
-
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
|
304
|
-
outstanding shares or beneficial ownership of such entity.
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
2. License Grants and Conditions
|
|
308
|
-
|
|
309
|
-
2.1. Grants
|
|
310
|
-
|
|
311
|
-
Each Contributor hereby grants You a world-wide, royalty-free,
|
|
312
|
-
non-exclusive license:
|
|
313
|
-
|
|
314
|
-
a. under intellectual property rights (other than patent or trademark)
|
|
315
|
-
Licensable by such Contributor to use, reproduce, make available,
|
|
316
|
-
modify, display, perform, distribute, and otherwise exploit its
|
|
317
|
-
Contributions, either on an unmodified basis, with Modifications, or as
|
|
318
|
-
part of a Larger Work; and
|
|
319
|
-
|
|
320
|
-
b. under Patent Claims of such Contributor to make, use, sell, offer for
|
|
321
|
-
sale, have made, import, and otherwise transfer either its Contributions
|
|
322
|
-
or its Contributor Version.
|
|
323
|
-
|
|
324
|
-
2.2. Effective Date
|
|
325
|
-
|
|
326
|
-
The licenses granted in Section 2.1 with respect to any Contribution become
|
|
327
|
-
effective for each Contribution on the date the Contributor first distributes
|
|
328
|
-
such Contribution.
|
|
329
|
-
|
|
330
|
-
2.3. Limitations on Grant Scope
|
|
331
|
-
|
|
332
|
-
The licenses granted in this Section 2 are the only rights granted under this
|
|
333
|
-
License. No additional rights or licenses will be implied from the distribution
|
|
334
|
-
or licensing of Covered Software under this License. Notwithstanding Section
|
|
335
|
-
2.1(b) above, no patent license is granted by a Contributor:
|
|
336
|
-
|
|
337
|
-
a. for any code that a Contributor has removed from Covered Software; or
|
|
338
|
-
|
|
339
|
-
b. for infringements caused by: (i) Your and any other third party’s
|
|
340
|
-
modifications of Covered Software, or (ii) the combination of its
|
|
341
|
-
Contributions with other software (except as part of its Contributor
|
|
342
|
-
Version); or
|
|
343
|
-
|
|
344
|
-
c. under Patent Claims infringed by Covered Software in the absence of its
|
|
345
|
-
Contributions.
|
|
346
|
-
|
|
347
|
-
This License does not grant any rights in the trademarks, service marks, or
|
|
348
|
-
logos of any Contributor (except as may be necessary to comply with the
|
|
349
|
-
notice requirements in Section 3.4).
|
|
350
|
-
|
|
351
|
-
2.4. Subsequent Licenses
|
|
352
|
-
|
|
353
|
-
No Contributor makes additional grants as a result of Your choice to
|
|
354
|
-
distribute the Covered Software under a subsequent version of this License
|
|
355
|
-
(see Section 10.2) or under the terms of a Secondary License (if permitted
|
|
356
|
-
under the terms of Section 3.3).
|
|
357
|
-
|
|
358
|
-
2.5. Representation
|
|
359
|
-
|
|
360
|
-
Each Contributor represents that the Contributor believes its Contributions
|
|
361
|
-
are its original creation(s) or it has sufficient rights to grant the
|
|
362
|
-
rights to its Contributions conveyed by this License.
|
|
363
|
-
|
|
364
|
-
2.6. Fair Use
|
|
365
|
-
|
|
366
|
-
This License is not intended to limit any rights You have under applicable
|
|
367
|
-
copyright doctrines of fair use, fair dealing, or other equivalents.
|
|
368
|
-
|
|
369
|
-
2.7. Conditions
|
|
370
|
-
|
|
371
|
-
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
|
372
|
-
Section 2.1.
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
3. Responsibilities
|
|
376
|
-
|
|
377
|
-
3.1. Distribution of Source Form
|
|
378
|
-
|
|
379
|
-
All distribution of Covered Software in Source Code Form, including any
|
|
380
|
-
Modifications that You create or to which You contribute, must be under the
|
|
381
|
-
terms of this License. You must inform recipients that the Source Code Form
|
|
382
|
-
of the Covered Software is governed by the terms of this License, and how
|
|
383
|
-
they can obtain a copy of this License. You may not attempt to alter or
|
|
384
|
-
restrict the recipients’ rights in the Source Code Form.
|
|
385
|
-
|
|
386
|
-
3.2. Distribution of Executable Form
|
|
387
|
-
|
|
388
|
-
If You distribute Covered Software in Executable Form then:
|
|
389
|
-
|
|
390
|
-
a. such Covered Software must also be made available in Source Code Form,
|
|
391
|
-
as described in Section 3.1, and You must inform recipients of the
|
|
392
|
-
Executable Form how they can obtain a copy of such Source Code Form by
|
|
393
|
-
reasonable means in a timely manner, at a charge no more than the cost
|
|
394
|
-
of distribution to the recipient; and
|
|
395
|
-
|
|
396
|
-
b. You may distribute such Executable Form under the terms of this License,
|
|
397
|
-
or sublicense it under different terms, provided that the license for
|
|
398
|
-
the Executable Form does not attempt to limit or alter the recipients’
|
|
399
|
-
rights in the Source Code Form under this License.
|
|
400
|
-
|
|
401
|
-
3.3. Distribution of a Larger Work
|
|
402
|
-
|
|
403
|
-
You may create and distribute a Larger Work under terms of Your choice,
|
|
404
|
-
provided that You also comply with the requirements of this License for the
|
|
405
|
-
Covered Software. If the Larger Work is a combination of Covered Software
|
|
406
|
-
with a work governed by one or more Secondary Licenses, and the Covered
|
|
407
|
-
Software is not Incompatible With Secondary Licenses, this License permits
|
|
408
|
-
You to additionally distribute such Covered Software under the terms of
|
|
409
|
-
such Secondary License(s), so that the recipient of the Larger Work may, at
|
|
410
|
-
their option, further distribute the Covered Software under the terms of
|
|
411
|
-
either this License or such Secondary License(s).
|
|
412
|
-
|
|
413
|
-
3.4. Notices
|
|
414
|
-
|
|
415
|
-
You may not remove or alter the substance of any license notices (including
|
|
416
|
-
copyright notices, patent notices, disclaimers of warranty, or limitations
|
|
417
|
-
of liability) contained within the Source Code Form of the Covered
|
|
418
|
-
Software, except that You may alter any license notices to the extent
|
|
419
|
-
required to remedy known factual inaccuracies.
|
|
420
|
-
|
|
421
|
-
3.5. Application of Additional Terms
|
|
422
|
-
|
|
423
|
-
You may choose to offer, and to charge a fee for, warranty, support,
|
|
424
|
-
indemnity or liability obligations to one or more recipients of Covered
|
|
425
|
-
Software. However, You may do so only on Your own behalf, and not on behalf
|
|
426
|
-
of any Contributor. You must make it absolutely clear that any such
|
|
427
|
-
warranty, support, indemnity, or liability obligation is offered by You
|
|
428
|
-
alone, and You hereby agree to indemnify every Contributor for any
|
|
429
|
-
liability incurred by such Contributor as a result of warranty, support,
|
|
430
|
-
indemnity or liability terms You offer. You may include additional
|
|
431
|
-
disclaimers of warranty and limitations of liability specific to any
|
|
432
|
-
jurisdiction.
|
|
433
|
-
|
|
434
|
-
4. Inability to Comply Due to Statute or Regulation
|
|
435
|
-
|
|
436
|
-
If it is impossible for You to comply with any of the terms of this License
|
|
437
|
-
with respect to some or all of the Covered Software due to statute, judicial
|
|
438
|
-
order, or regulation then You must: (a) comply with the terms of this License
|
|
439
|
-
to the maximum extent possible; and (b) describe the limitations and the code
|
|
440
|
-
they affect. Such description must be placed in a text file included with all
|
|
441
|
-
distributions of the Covered Software under this License. Except to the
|
|
442
|
-
extent prohibited by statute or regulation, such description must be
|
|
443
|
-
sufficiently detailed for a recipient of ordinary skill to be able to
|
|
444
|
-
understand it.
|
|
445
|
-
|
|
446
|
-
5. Termination
|
|
447
|
-
|
|
448
|
-
5.1. The rights granted under this License will terminate automatically if You
|
|
449
|
-
fail to comply with any of its terms. However, if You become compliant,
|
|
450
|
-
then the rights granted under this License from a particular Contributor
|
|
451
|
-
are reinstated (a) provisionally, unless and until such Contributor
|
|
452
|
-
explicitly and finally terminates Your grants, and (b) on an ongoing basis,
|
|
453
|
-
if such Contributor fails to notify You of the non-compliance by some
|
|
454
|
-
reasonable means prior to 60 days after You have come back into compliance.
|
|
455
|
-
Moreover, Your grants from a particular Contributor are reinstated on an
|
|
456
|
-
ongoing basis if such Contributor notifies You of the non-compliance by
|
|
457
|
-
some reasonable means, this is the first time You have received notice of
|
|
458
|
-
non-compliance with this License from such Contributor, and You become
|
|
459
|
-
compliant prior to 30 days after Your receipt of the notice.
|
|
460
|
-
|
|
461
|
-
5.2. If You initiate litigation against any entity by asserting a patent
|
|
462
|
-
infringement claim (excluding declaratory judgment actions, counter-claims,
|
|
463
|
-
and cross-claims) alleging that a Contributor Version directly or
|
|
464
|
-
indirectly infringes any patent, then the rights granted to You by any and
|
|
465
|
-
all Contributors for the Covered Software under Section 2.1 of this License
|
|
466
|
-
shall terminate.
|
|
467
|
-
|
|
468
|
-
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
|
|
469
|
-
license agreements (excluding distributors and resellers) which have been
|
|
470
|
-
validly granted by You or Your distributors under this License prior to
|
|
471
|
-
termination shall survive termination.
|
|
472
|
-
|
|
473
|
-
6. Disclaimer of Warranty
|
|
474
|
-
|
|
475
|
-
Covered Software is provided under this License on an “as is” basis, without
|
|
476
|
-
warranty of any kind, either expressed, implied, or statutory, including,
|
|
477
|
-
without limitation, warranties that the Covered Software is free of defects,
|
|
478
|
-
merchantable, fit for a particular purpose or non-infringing. The entire
|
|
479
|
-
risk as to the quality and performance of the Covered Software is with You.
|
|
480
|
-
Should any Covered Software prove defective in any respect, You (not any
|
|
481
|
-
Contributor) assume the cost of any necessary servicing, repair, or
|
|
482
|
-
correction. This disclaimer of warranty constitutes an essential part of this
|
|
483
|
-
License. No use of any Covered Software is authorized under this License
|
|
484
|
-
except under this disclaimer.
|
|
485
|
-
|
|
486
|
-
7. Limitation of Liability
|
|
487
|
-
|
|
488
|
-
Under no circumstances and under no legal theory, whether tort (including
|
|
489
|
-
negligence), contract, or otherwise, shall any Contributor, or anyone who
|
|
490
|
-
distributes Covered Software as permitted above, be liable to You for any
|
|
491
|
-
direct, indirect, special, incidental, or consequential damages of any
|
|
492
|
-
character including, without limitation, damages for lost profits, loss of
|
|
493
|
-
goodwill, work stoppage, computer failure or malfunction, or any and all
|
|
494
|
-
other commercial damages or losses, even if such party shall have been
|
|
495
|
-
informed of the possibility of such damages. This limitation of liability
|
|
496
|
-
shall not apply to liability for death or personal injury resulting from such
|
|
497
|
-
party’s negligence to the extent applicable law prohibits such limitation.
|
|
498
|
-
Some jurisdictions do not allow the exclusion or limitation of incidental or
|
|
499
|
-
consequential damages, so this exclusion and limitation may not apply to You.
|
|
500
|
-
|
|
501
|
-
8. Litigation
|
|
502
|
-
|
|
503
|
-
Any litigation relating to this License may be brought only in the courts of
|
|
504
|
-
a jurisdiction where the defendant maintains its principal place of business
|
|
505
|
-
and such litigation shall be governed by laws of that jurisdiction, without
|
|
506
|
-
reference to its conflict-of-law provisions. Nothing in this Section shall
|
|
507
|
-
prevent a party’s ability to bring cross-claims or counter-claims.
|
|
508
|
-
|
|
509
|
-
9. Miscellaneous
|
|
510
|
-
|
|
511
|
-
This License represents the complete agreement concerning the subject matter
|
|
512
|
-
hereof. If any provision of this License is held to be unenforceable, such
|
|
513
|
-
provision shall be reformed only to the extent necessary to make it
|
|
514
|
-
enforceable. Any law or regulation which provides that the language of a
|
|
515
|
-
contract shall be construed against the drafter shall not be used to construe
|
|
516
|
-
this License against a Contributor.
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
10. Versions of the License
|
|
520
|
-
|
|
521
|
-
10.1. New Versions
|
|
522
|
-
|
|
523
|
-
Mozilla Foundation is the license steward. Except as provided in Section
|
|
524
|
-
10.3, no one other than the license steward has the right to modify or
|
|
525
|
-
publish new versions of this License. Each version will be given a
|
|
526
|
-
distinguishing version number.
|
|
527
|
-
|
|
528
|
-
10.2. Effect of New Versions
|
|
529
|
-
|
|
530
|
-
You may distribute the Covered Software under the terms of the version of
|
|
531
|
-
the License under which You originally received the Covered Software, or
|
|
532
|
-
under the terms of any subsequent version published by the license
|
|
533
|
-
steward.
|
|
534
|
-
|
|
535
|
-
10.3. Modified Versions
|
|
536
|
-
|
|
537
|
-
If you create software not governed by this License, and you want to
|
|
538
|
-
create a new license for such software, you may create and use a modified
|
|
539
|
-
version of this License if you rename the license and remove any
|
|
540
|
-
references to the name of the license steward (except to note that such
|
|
541
|
-
modified license differs from this License).
|
|
542
|
-
|
|
543
|
-
10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
|
|
544
|
-
If You choose to distribute Source Code Form that is Incompatible With
|
|
545
|
-
Secondary Licenses under the terms of this version of the License, the
|
|
546
|
-
notice described in Exhibit B of this License must be attached.
|
|
547
|
-
|
|
548
|
-
Exhibit A - Source Code Form License Notice
|
|
549
|
-
|
|
550
|
-
This Source Code Form is subject to the
|
|
551
|
-
terms of the Mozilla Public License, v.
|
|
552
|
-
2.0. If a copy of the MPL was not
|
|
553
|
-
distributed with this file, You can
|
|
554
|
-
obtain one at
|
|
555
|
-
http://mozilla.org/MPL/2.0/.
|
|
556
|
-
|
|
557
|
-
If it is not possible or desirable to put the notice in a particular file, then
|
|
558
|
-
You may include the notice in a location (such as a LICENSE file in a relevant
|
|
559
|
-
directory) where a recipient would be likely to look for such a notice.
|
|
560
|
-
|
|
561
|
-
You may add additional accurate notices of copyright ownership.
|
|
562
|
-
|
|
563
|
-
Exhibit B - “Incompatible With Secondary Licenses” Notice
|
|
564
|
-
|
|
565
|
-
This Source Code Form is “Incompatible
|
|
566
|
-
With Secondary Licenses”, as defined by
|
|
567
|
-
the Mozilla Public License, v. 2.0.
|
|
568
|
-
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# DOMPurify
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/dompurify) [](https://github.com/cure53/DOMPurify/blob/main/LICENSE)
|
|
3
|
+
[](https://www.npmjs.com/package/dompurify) [](https://github.com/cure53/DOMPurify/blob/main/LICENSE) [](https://www.npmjs.com/package/dompurify) [](https://github.com/cure53/DOMPurify/network/dependents) 
|
|
4
4
|
|
|
5
|
-
](https://github.com/cure53/DOMPurify/actions/workflows/build-and-test.yml) [](https://www.bestpractices.dev/projects/12162) [](https://scorecard.dev/viewer/?uri=github.com/cure53/DOMPurify) [](https://badge.socket.dev/npm/package/dompurify/latest) [](https://cloudback.it)
|
|
6
6
|
|
|
7
7
|
DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG.
|
|
8
8
|
|
|
9
|
-
It's also very simple to use and get started with. DOMPurify was [started in February 2014](https://github.com/cure53/DOMPurify/commit/a630922616927373485e0e787ab19e73e3691b2b) and, meanwhile, has reached version **v3.4.
|
|
9
|
+
It's also very simple to use and get started with. DOMPurify was [started in February 2014](https://github.com/cure53/DOMPurify/commit/a630922616927373485e0e787ab19e73e3691b2b) and, meanwhile, has reached version **v3.4.5**.
|
|
10
10
|
|
|
11
11
|
DOMPurify runs as JavaScript and works in all modern browsers (Safari (10+), Opera (15+), Edge, Firefox and Chrome - as well as almost anything else using Blink, Gecko or WebKit). It doesn't break on MSIE or other legacy browsers. It simply does nothing.
|
|
12
12
|
|
|
@@ -463,7 +463,7 @@ DOMPurify.addHook(
|
|
|
463
463
|
|
|
464
464
|
## Continuous Integration
|
|
465
465
|
|
|
466
|
-
We are currently using GitHub Actions in combination with
|
|
466
|
+
We are currently using GitHub Actions in combination with Playwright. This gives us the possibility to confirm for each and every commit that all is going according to plan in relevant modern browsers. Check out the build logs here: https://github.com/cure53/DOMPurify/actions
|
|
467
467
|
|
|
468
468
|
You can further run local tests by executing `npm run test`.
|
|
469
469
|
|
|
@@ -519,4 +519,4 @@ Feature releases will not be announced to this list.
|
|
|
519
519
|
|
|
520
520
|
Many people have helped DOMPurify become what it is today, and they deserve to be acknowledged!
|
|
521
521
|
|
|
522
|
-
[kodareef5](https://github.com/kodareef5), [DavidOliver](https://github.com/DavidOliver), [1Jesper1](https://github.com/1Jesper1), [bencalif](https://github.com/bencalif), [trace37labs](https://github.com/trace37labs), [eddieran](https://github.com/eddieran), [christos-eth](https://github.com/christos-eth), [researchatfluidattacks](https://github.com/researchatfluidattacks), [frevadiscor](https://github.com/frevadiscor), [Rotzbua](https://github.com/Rotzbua), [binhpv](https://github.com/binhpv), [MariusRumpf](https://github.com/MariusRumpf), [prasadrajandran](https://github.com/prasadrajandran), [Cybozu 💛💸](https://github.com/cybozu), [hata6502 💸](https://github.com/hata6502), [openclaw 💸](https://github.com/openclaw), [intra-mart-dh 💸](https://github.com/intra-mart-dh), [nelstrom ❤️](https://github.com/nelstrom), [hash_kitten ❤️](https://twitter.com/hash_kitten), [kevin_mizu ❤️](https://twitter.com/kevin_mizu), [icesfont ❤️](https://github.com/icesfont), [reduckted ❤️](https://github.com/reduckted), [dcramer 💸](https://github.com/dcramer), [JGraph 💸](https://github.com/jgraph), [baekilda 💸](https://github.com/baekilda), [Healthchecks 💸](https://github.com/healthchecks), [Sentry 💸](https://github.com/getsentry), [jarrodldavis 💸](https://github.com/jarrodldavis), [CynegeticIO](https://github.com/CynegeticIO), [ssi02014 ❤️](https://github.com/ssi02014), [GrantGryczan](https://github.com/GrantGryczan), [Lowdefy](https://twitter.com/lowdefy), [granlem](https://twitter.com/MaximeVeit), [oreoshake](https://github.com/oreoshake), [tdeekens ❤️](https://github.com/tdeekens), [peernohell ❤️](https://github.com/peernohell), [is2ei](https://github.com/is2ei), [SoheilKhodayari](https://github.com/SoheilKhodayari), [franktopel](https://github.com/franktopel), [NateScarlet](https://github.com/NateScarlet), [neilj](https://github.com/neilj), [fhemberger](https://github.com/fhemberger), [Joris-van-der-Wel](https://github.com/Joris-van-der-Wel), [ydaniv](https://github.com/ydaniv), [terjanq](https://twitter.com/terjanq), [filedescriptor](https://github.com/filedescriptor), [ConradIrwin](https://github.com/ConradIrwin), [gibson042](https://github.com/gibson042), [choumx](https://github.com/choumx), [0xSobky](https://github.com/0xSobky), [styfle](https://github.com/styfle), [koto](https://github.com/koto), [tlau88](https://github.com/tlau88), [strugee](https://github.com/strugee), [oparoz](https://github.com/oparoz), [mathiasbynens](https://github.com/mathiasbynens), [edg2s](https://github.com/edg2s), [dnkolegov](https://github.com/dnkolegov), [dhardtke](https://github.com/dhardtke), [wirehead](https://github.com/wirehead), [thorn0](https://github.com/thorn0), [styu](https://github.com/styu), [mozfreddyb](https://github.com/mozfreddyb), [mikesamuel](https://github.com/mikesamuel), [jorangreef](https://github.com/jorangreef), [jimmyhchan](https://github.com/jimmyhchan), [jameydeorio](https://github.com/jameydeorio), [jameskraus](https://github.com/jameskraus), [hyderali](https://github.com/hyderali), [hansottowirtz](https://github.com/hansottowirtz), [hackvertor](https://github.com/hackvertor), [freddyb](https://github.com/freddyb), [flavorjones](https://github.com/flavorjones), [djfarrelly](https://github.com/djfarrelly), [devd](https://github.com/devd), [camerondunford](https://github.com/camerondunford), [buu700](https://github.com/buu700), [buildog](https://github.com/buildog), [alabiaga](https://github.com/alabiaga), [Vector919](https://github.com/Vector919), [Robbert](https://github.com/Robbert), [GreLI](https://github.com/GreLI), [FuzzySockets](https://github.com/FuzzySockets), [ArtemBernatskyy](https://github.com/ArtemBernatskyy), [@garethheyes](https://twitter.com/garethheyes), [@shafigullin](https://twitter.com/shafigullin), [@mmrupp](https://twitter.com/mmrupp), [@irsdl](https://twitter.com/irsdl),[ShikariSenpai](https://github.com/ShikariSenpai), [ansjdnakjdnajkd](https://github.com/ansjdnakjdnajkd), [@asutherland](https://twitter.com/asutherland), [@mathias](https://twitter.com/mathias), [@cgvwzq](https://twitter.com/cgvwzq), [@robbertatwork](https://twitter.com/robbertatwork), [@giutro](https://twitter.com/giutro), [@CmdEngineer\_](https://twitter.com/CmdEngineer_), [@avr4mit](https://twitter.com/avr4mit), [davecardwell](https://github.com/davecardwell) and especially [@securitymb ❤️](https://twitter.com/securitymb) & [@masatokinugawa ❤️](https://twitter.com/masatokinugawa)
|
|
522
|
+
[lukewarlow](https://github.com/lukewarlow), [DEMON1A](https://github.com/DEMON1A), [fg0x0](https://github.com/fg0x0), [kodareef5](https://github.com/kodareef5), [DavidOliver](https://github.com/DavidOliver), [1Jesper1](https://github.com/1Jesper1), [bencalif](https://github.com/bencalif), [trace37labs](https://github.com/trace37labs), [eddieran](https://github.com/eddieran), [christos-eth](https://github.com/christos-eth), [researchatfluidattacks](https://github.com/researchatfluidattacks), [frevadiscor](https://github.com/frevadiscor), [Rotzbua](https://github.com/Rotzbua), [binhpv](https://github.com/binhpv), [MariusRumpf](https://github.com/MariusRumpf), [prasadrajandran](https://github.com/prasadrajandran), [Cybozu 💛💸](https://github.com/cybozu), [hata6502 💸](https://github.com/hata6502), [openclaw 💸](https://github.com/openclaw), [intra-mart-dh 💸](https://github.com/intra-mart-dh), [nelstrom ❤️](https://github.com/nelstrom), [hash_kitten ❤️](https://twitter.com/hash_kitten), [kevin_mizu ❤️](https://twitter.com/kevin_mizu), [icesfont ❤️](https://github.com/icesfont), [reduckted ❤️](https://github.com/reduckted), [dcramer 💸](https://github.com/dcramer), [JGraph 💸](https://github.com/jgraph), [baekilda 💸](https://github.com/baekilda), [Healthchecks 💸](https://github.com/healthchecks), [Sentry 💸](https://github.com/getsentry), [jarrodldavis 💸](https://github.com/jarrodldavis), [CynegeticIO](https://github.com/CynegeticIO), [ssi02014 ❤️](https://github.com/ssi02014), [GrantGryczan](https://github.com/GrantGryczan), [Lowdefy](https://twitter.com/lowdefy), [granlem](https://twitter.com/MaximeVeit), [oreoshake](https://github.com/oreoshake), [tdeekens ❤️](https://github.com/tdeekens), [peernohell ❤️](https://github.com/peernohell), [is2ei](https://github.com/is2ei), [SoheilKhodayari](https://github.com/SoheilKhodayari), [franktopel](https://github.com/franktopel), [NateScarlet](https://github.com/NateScarlet), [neilj](https://github.com/neilj), [fhemberger](https://github.com/fhemberger), [Joris-van-der-Wel](https://github.com/Joris-van-der-Wel), [ydaniv](https://github.com/ydaniv), [terjanq](https://twitter.com/terjanq), [filedescriptor](https://github.com/filedescriptor), [ConradIrwin](https://github.com/ConradIrwin), [gibson042](https://github.com/gibson042), [choumx](https://github.com/choumx), [0xSobky](https://github.com/0xSobky), [styfle](https://github.com/styfle), [koto](https://github.com/koto), [tlau88](https://github.com/tlau88), [strugee](https://github.com/strugee), [oparoz](https://github.com/oparoz), [mathiasbynens](https://github.com/mathiasbynens), [edg2s](https://github.com/edg2s), [dnkolegov](https://github.com/dnkolegov), [dhardtke](https://github.com/dhardtke), [wirehead](https://github.com/wirehead), [thorn0](https://github.com/thorn0), [styu](https://github.com/styu), [mozfreddyb](https://github.com/mozfreddyb), [mikesamuel](https://github.com/mikesamuel), [jorangreef](https://github.com/jorangreef), [jimmyhchan](https://github.com/jimmyhchan), [jameydeorio](https://github.com/jameydeorio), [jameskraus](https://github.com/jameskraus), [hyderali](https://github.com/hyderali), [hansottowirtz](https://github.com/hansottowirtz), [hackvertor](https://github.com/hackvertor), [freddyb](https://github.com/freddyb), [flavorjones](https://github.com/flavorjones), [djfarrelly](https://github.com/djfarrelly), [devd](https://github.com/devd), [camerondunford](https://github.com/camerondunford), [buu700](https://github.com/buu700), [buildog](https://github.com/buildog), [alabiaga](https://github.com/alabiaga), [Vector919](https://github.com/Vector919), [Robbert](https://github.com/Robbert), [GreLI](https://github.com/GreLI), [FuzzySockets](https://github.com/FuzzySockets), [ArtemBernatskyy](https://github.com/ArtemBernatskyy), [@garethheyes](https://twitter.com/garethheyes), [@shafigullin](https://twitter.com/shafigullin), [@mmrupp](https://twitter.com/mmrupp), [@irsdl](https://twitter.com/irsdl),[ShikariSenpai](https://github.com/ShikariSenpai), [ansjdnakjdnajkd](https://github.com/ansjdnakjdnajkd), [@asutherland](https://twitter.com/asutherland), [@mathias](https://twitter.com/mathias), [@cgvwzq](https://twitter.com/cgvwzq), [@robbertatwork](https://twitter.com/robbertatwork), [@giutro](https://twitter.com/giutro), [@CmdEngineer\_](https://twitter.com/CmdEngineer_), [@avr4mit](https://twitter.com/avr4mit), [davecardwell](https://github.com/davecardwell) and especially [@securitymb ❤️](https://twitter.com/securitymb) & [@masatokinugawa ❤️](https://twitter.com/masatokinugawa)
|
package/dist/purify.cjs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @license DOMPurify 3.4.
|
|
1
|
+
/*! @license DOMPurify 3.4.5 | (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.5/LICENSE */
|
|
2
2
|
|
|
3
3
|
import { TrustedTypePolicy, TrustedTypesWindow, TrustedHTML } from 'trusted-types/lib/index.js';
|
|
4
4
|
|
package/dist/purify.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @license DOMPurify 3.4.
|
|
1
|
+
/*! @license DOMPurify 3.4.5 | (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.5/LICENSE */
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -312,7 +312,7 @@ const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mgly
|
|
|
312
312
|
const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
|
|
313
313
|
const text = freeze(['#text']);
|
|
314
314
|
|
|
315
|
-
const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', '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']);
|
|
315
|
+
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']);
|
|
316
316
|
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', '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-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']);
|
|
317
317
|
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']);
|
|
318
318
|
const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
|
|
@@ -396,7 +396,7 @@ const _createHooksMap = function _createHooksMap() {
|
|
|
396
396
|
function createDOMPurify() {
|
|
397
397
|
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
398
398
|
const DOMPurify = root => createDOMPurify(root);
|
|
399
|
-
DOMPurify.version = '3.4.
|
|
399
|
+
DOMPurify.version = '3.4.5';
|
|
400
400
|
DOMPurify.removed = [];
|
|
401
401
|
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
|
|
402
402
|
// Not running in a browser, provide a factory function
|
|
@@ -423,6 +423,7 @@ function createDOMPurify() {
|
|
|
423
423
|
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
|
424
424
|
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
|
425
425
|
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
|
|
426
|
+
const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeType') : null;
|
|
426
427
|
// As per issue #47, the web-components registry is inherited by a
|
|
427
428
|
// new document created via createHTMLDocument. As per the spec
|
|
428
429
|
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
|
|
@@ -976,6 +977,40 @@ function createDOMPurify() {
|
|
|
976
977
|
// eslint-disable-next-line no-bitwise
|
|
977
978
|
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
|
978
979
|
};
|
|
980
|
+
/**
|
|
981
|
+
* Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
|
|
982
|
+
* character data of an element subtree. Used as the final safety net for
|
|
983
|
+
* SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions
|
|
984
|
+
* which only form after text-node normalization (e.g. fragments split across
|
|
985
|
+
* stripped elements) cannot survive into a template-evaluating framework.
|
|
986
|
+
*
|
|
987
|
+
* Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`
|
|
988
|
+
* in place rather than round-tripping through innerHTML. This preserves
|
|
989
|
+
* descendant node references (important for IN_PLACE callers), avoids a
|
|
990
|
+
* serialize/reparse cycle, and reads literal character data — which means
|
|
991
|
+
* `<%...%>` in text content matches the ERB regex against its real bytes
|
|
992
|
+
* instead of the HTML-entity-escaped form innerHTML would produce.
|
|
993
|
+
*
|
|
994
|
+
* Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for
|
|
995
|
+
* attributes is performed during the per-node `_sanitizeAttributes` pass.
|
|
996
|
+
*
|
|
997
|
+
* @param node The root element whose character data should be scrubbed.
|
|
998
|
+
*/
|
|
999
|
+
const _scrubTemplateExpressions = function _scrubTemplateExpressions(node) {
|
|
1000
|
+
node.normalize();
|
|
1001
|
+
const walker = createNodeIterator.call(node.ownerDocument || node, node,
|
|
1002
|
+
// eslint-disable-next-line no-bitwise
|
|
1003
|
+
NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
|
|
1004
|
+
let currentNode = walker.nextNode();
|
|
1005
|
+
while (currentNode) {
|
|
1006
|
+
let data = currentNode.data;
|
|
1007
|
+
arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
|
|
1008
|
+
data = stringReplace(data, expr, ' ');
|
|
1009
|
+
});
|
|
1010
|
+
currentNode.data = data;
|
|
1011
|
+
currentNode = walker.nextNode();
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
979
1014
|
/**
|
|
980
1015
|
* _isClobbered
|
|
981
1016
|
*
|
|
@@ -986,13 +1021,31 @@ function createDOMPurify() {
|
|
|
986
1021
|
return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function');
|
|
987
1022
|
};
|
|
988
1023
|
/**
|
|
989
|
-
* Checks whether the given object is a DOM node
|
|
1024
|
+
* Checks whether the given object is a DOM node, including nodes that
|
|
1025
|
+
* originate from a different window/realm (e.g. an iframe's
|
|
1026
|
+
* contentDocument). The previous `value instanceof Node` check was
|
|
1027
|
+
* realm-bound: nodes from a different window failed it, causing
|
|
1028
|
+
* sanitize() to silently stringify them and reset IN_PLACE to false,
|
|
1029
|
+
* returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
|
|
1030
|
+
*
|
|
1031
|
+
* Implementation: call the cached `nodeType` getter from Node.prototype
|
|
1032
|
+
* directly on the value. This bypasses any clobbered instance property
|
|
1033
|
+
* (e.g. a child element named "nodeType") and works across realms
|
|
1034
|
+
* because the WebIDL `nodeType` getter reads an internal slot that
|
|
1035
|
+
* every real Node has, regardless of which window minted it.
|
|
990
1036
|
*
|
|
991
1037
|
* @param value object to check whether it's a DOM node
|
|
992
|
-
* @return true
|
|
1038
|
+
* @return true if value is a DOM node from any realm
|
|
993
1039
|
*/
|
|
994
1040
|
const _isNode = function _isNode(value) {
|
|
995
|
-
|
|
1041
|
+
if (!getNodeType || typeof value !== 'object' || value === null) {
|
|
1042
|
+
return false;
|
|
1043
|
+
}
|
|
1044
|
+
try {
|
|
1045
|
+
return typeof getNodeType(value) === 'number';
|
|
1046
|
+
} catch (_) {
|
|
1047
|
+
return false;
|
|
1048
|
+
}
|
|
996
1049
|
};
|
|
997
1050
|
function _executeHooks(hooks, currentNode, data) {
|
|
998
1051
|
arrayForEach(hooks, hook => {
|
|
@@ -1396,7 +1449,7 @@ function createDOMPurify() {
|
|
|
1396
1449
|
/* Sanitize attached shadow roots before the main iterator runs.
|
|
1397
1450
|
The iterator does not descend into shadow trees. */
|
|
1398
1451
|
_sanitizeAttachedShadowRoots2(dirty);
|
|
1399
|
-
} else if (dirty
|
|
1452
|
+
} else if (_isNode(dirty)) {
|
|
1400
1453
|
/* If dirty is a DOM element, append to an empty document to avoid
|
|
1401
1454
|
elements being stripped by the parser */
|
|
1402
1455
|
body = _initDocument('<!---->');
|
|
@@ -1447,17 +1500,15 @@ function createDOMPurify() {
|
|
|
1447
1500
|
}
|
|
1448
1501
|
/* If we sanitized `dirty` in-place, return it. */
|
|
1449
1502
|
if (IN_PLACE) {
|
|
1503
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
1504
|
+
_scrubTemplateExpressions(dirty);
|
|
1505
|
+
}
|
|
1450
1506
|
return dirty;
|
|
1451
1507
|
}
|
|
1452
1508
|
/* Return sanitized string or DOM */
|
|
1453
1509
|
if (RETURN_DOM) {
|
|
1454
1510
|
if (SAFE_FOR_TEMPLATES) {
|
|
1455
|
-
body
|
|
1456
|
-
let html = body.innerHTML;
|
|
1457
|
-
arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
|
|
1458
|
-
html = stringReplace(html, expr, ' ');
|
|
1459
|
-
});
|
|
1460
|
-
body.innerHTML = html;
|
|
1511
|
+
_scrubTemplateExpressions(body);
|
|
1461
1512
|
}
|
|
1462
1513
|
if (RETURN_DOM_FRAGMENT) {
|
|
1463
1514
|
returnNode = createDocumentFragment.call(body.ownerDocument);
|