Skip to content

Commit 3990b7e

Browse files
authored
Merge pull request #1038 from cure53/main
Getting 3.x branch ready for 3.2.2 release
2 parents 7f154b3 + 3b4b5e9 commit 3990b7e

18 files changed

+375
-212
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG.
88

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.2.1**.
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.2.2**.
1010

1111
DOMPurify is written in 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.
1212

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dompurify",
3-
"version": "3.2.1",
3+
"version": "3.2.2",
44
"homepage": "https://github.com/cure53/DOMPurify",
55
"author": "Cure53 <[email protected]>",
66
"description": "A DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG",

dist/purify.cjs.d.ts

+43-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/*! @license DOMPurify 3.2.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.1/LICENSE */
1+
/// <reference types="trusted-types" />
2+
/*! @license DOMPurify 3.2.2 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.2/LICENSE */
23

34
/**
45
* Configuration to control DOMPurify behavior.
@@ -297,7 +298,21 @@ interface DOMPurify {
297298
* @param entryPoint entry point for the hook to add
298299
* @param hookFunction function to execute
299300
*/
300-
addHook(entryPoint: BasicHookName, hookFunction: Hook): void;
301+
addHook(entryPoint: BasicHookName, hookFunction: NodeHook): void;
302+
/**
303+
* Adds a DOMPurify hook.
304+
*
305+
* @param entryPoint entry point for the hook to add
306+
* @param hookFunction function to execute
307+
*/
308+
addHook(entryPoint: ElementHookName, hookFunction: ElementHook): void;
309+
/**
310+
* Adds a DOMPurify hook.
311+
*
312+
* @param entryPoint entry point for the hook to add
313+
* @param hookFunction function to execute
314+
*/
315+
addHook(entryPoint: DocumentFragmentHookName, hookFunction: DocumentFragmentHook): void;
301316
/**
302317
* Adds a DOMPurify hook.
303318
*
@@ -319,7 +334,23 @@ interface DOMPurify {
319334
* @param entryPoint entry point for the hook to remove
320335
* @returns removed(popped) hook
321336
*/
322-
removeHook(entryPoint: BasicHookName): Hook | undefined;
337+
removeHook(entryPoint: BasicHookName): NodeHook | undefined;
338+
/**
339+
* Remove a DOMPurify hook at a given entryPoint
340+
* (pops it from the stack of hooks if more are present)
341+
*
342+
* @param entryPoint entry point for the hook to remove
343+
* @returns removed(popped) hook
344+
*/
345+
removeHook(entryPoint: ElementHookName): ElementHook | undefined;
346+
/**
347+
* Remove a DOMPurify hook at a given entryPoint
348+
* (pops it from the stack of hooks if more are present)
349+
*
350+
* @param entryPoint entry point for the hook to remove
351+
* @returns removed(popped) hook
352+
*/
353+
removeHook(entryPoint: DocumentFragmentHookName): DocumentFragmentHook | undefined;
323354
/**
324355
* Remove a DOMPurify hook at a given entryPoint
325356
* (pops it from the stack of hooks if more are present)
@@ -369,13 +400,17 @@ interface RemovedAttribute {
369400
*/
370401
from: Node;
371402
}
372-
type BasicHookName = 'beforeSanitizeElements' | 'afterSanitizeElements' | 'beforeSanitizeAttributes' | 'afterSanitizeAttributes' | 'beforeSanitizeShadowDOM' | 'uponSanitizeShadowNode' | 'afterSanitizeShadowDOM';
403+
type BasicHookName = 'beforeSanitizeElements' | 'afterSanitizeElements' | 'uponSanitizeShadowNode';
404+
type ElementHookName = 'beforeSanitizeAttributes' | 'afterSanitizeAttributes';
405+
type DocumentFragmentHookName = 'beforeSanitizeShadowDOM' | 'afterSanitizeShadowDOM';
373406
type UponSanitizeElementHookName = 'uponSanitizeElement';
374407
type UponSanitizeAttributeHookName = 'uponSanitizeAttribute';
375-
type HookName = BasicHookName | UponSanitizeElementHookName | UponSanitizeAttributeHookName;
376-
type Hook = (this: DOMPurify, currentNode: Node, hookEvent: null, config: Config) => void;
408+
type HookName = BasicHookName | ElementHookName | DocumentFragmentHookName | UponSanitizeElementHookName | UponSanitizeAttributeHookName;
409+
type NodeHook = (this: DOMPurify, currentNode: Node, hookEvent: null, config: Config) => void;
410+
type ElementHook = (this: DOMPurify, currentNode: Element, hookEvent: null, config: Config) => void;
411+
type DocumentFragmentHook = (this: DOMPurify, currentNode: DocumentFragment, hookEvent: null, config: Config) => void;
377412
type UponSanitizeElementHook = (this: DOMPurify, currentNode: Node, hookEvent: UponSanitizeElementHookEvent, config: Config) => void;
378-
type UponSanitizeAttributeHook = (this: DOMPurify, currentNode: Node, hookEvent: UponSanitizeAttributeHookEvent, config: Config) => void;
413+
type UponSanitizeAttributeHook = (this: DOMPurify, currentNode: Element, hookEvent: UponSanitizeAttributeHookEvent, config: Config) => void;
379414
interface UponSanitizeElementHookEvent {
380415
tagName: string;
381416
allowedTags: Record<string, boolean>;
@@ -396,7 +431,7 @@ type WindowLike = Pick<typeof globalThis, 'DocumentFragment' | 'HTMLTemplateElem
396431
trustedTypes?: typeof window.trustedTypes;
397432
};
398433

399-
export { type Config, type DOMPurify, type Hook, type HookName, type RemovedAttribute, type RemovedElement, type UponSanitizeAttributeHook, type UponSanitizeAttributeHookEvent, type UponSanitizeElementHook, type UponSanitizeElementHookEvent, type WindowLike };
434+
export { type Config, type DOMPurify, type DocumentFragmentHook, type ElementHook, type HookName, type NodeHook, type RemovedAttribute, type RemovedElement, type UponSanitizeAttributeHook, type UponSanitizeAttributeHookEvent, type UponSanitizeElementHook, type UponSanitizeElementHookEvent, type WindowLike };
400435

401436
// @ts-ignore
402437
export = _default;

dist/purify.cjs.js

+32-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/purify.cjs.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/purify.es.d.mts

+43-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/*! @license DOMPurify 3.2.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.1/LICENSE */
1+
/// <reference types="trusted-types" />
2+
/*! @license DOMPurify 3.2.2 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.2/LICENSE */
23

34
/**
45
* Configuration to control DOMPurify behavior.
@@ -297,7 +298,21 @@ interface DOMPurify {
297298
* @param entryPoint entry point for the hook to add
298299
* @param hookFunction function to execute
299300
*/
300-
addHook(entryPoint: BasicHookName, hookFunction: Hook): void;
301+
addHook(entryPoint: BasicHookName, hookFunction: NodeHook): void;
302+
/**
303+
* Adds a DOMPurify hook.
304+
*
305+
* @param entryPoint entry point for the hook to add
306+
* @param hookFunction function to execute
307+
*/
308+
addHook(entryPoint: ElementHookName, hookFunction: ElementHook): void;
309+
/**
310+
* Adds a DOMPurify hook.
311+
*
312+
* @param entryPoint entry point for the hook to add
313+
* @param hookFunction function to execute
314+
*/
315+
addHook(entryPoint: DocumentFragmentHookName, hookFunction: DocumentFragmentHook): void;
301316
/**
302317
* Adds a DOMPurify hook.
303318
*
@@ -319,7 +334,23 @@ interface DOMPurify {
319334
* @param entryPoint entry point for the hook to remove
320335
* @returns removed(popped) hook
321336
*/
322-
removeHook(entryPoint: BasicHookName): Hook | undefined;
337+
removeHook(entryPoint: BasicHookName): NodeHook | undefined;
338+
/**
339+
* Remove a DOMPurify hook at a given entryPoint
340+
* (pops it from the stack of hooks if more are present)
341+
*
342+
* @param entryPoint entry point for the hook to remove
343+
* @returns removed(popped) hook
344+
*/
345+
removeHook(entryPoint: ElementHookName): ElementHook | undefined;
346+
/**
347+
* Remove a DOMPurify hook at a given entryPoint
348+
* (pops it from the stack of hooks if more are present)
349+
*
350+
* @param entryPoint entry point for the hook to remove
351+
* @returns removed(popped) hook
352+
*/
353+
removeHook(entryPoint: DocumentFragmentHookName): DocumentFragmentHook | undefined;
323354
/**
324355
* Remove a DOMPurify hook at a given entryPoint
325356
* (pops it from the stack of hooks if more are present)
@@ -369,13 +400,17 @@ interface RemovedAttribute {
369400
*/
370401
from: Node;
371402
}
372-
type BasicHookName = 'beforeSanitizeElements' | 'afterSanitizeElements' | 'beforeSanitizeAttributes' | 'afterSanitizeAttributes' | 'beforeSanitizeShadowDOM' | 'uponSanitizeShadowNode' | 'afterSanitizeShadowDOM';
403+
type BasicHookName = 'beforeSanitizeElements' | 'afterSanitizeElements' | 'uponSanitizeShadowNode';
404+
type ElementHookName = 'beforeSanitizeAttributes' | 'afterSanitizeAttributes';
405+
type DocumentFragmentHookName = 'beforeSanitizeShadowDOM' | 'afterSanitizeShadowDOM';
373406
type UponSanitizeElementHookName = 'uponSanitizeElement';
374407
type UponSanitizeAttributeHookName = 'uponSanitizeAttribute';
375-
type HookName = BasicHookName | UponSanitizeElementHookName | UponSanitizeAttributeHookName;
376-
type Hook = (this: DOMPurify, currentNode: Node, hookEvent: null, config: Config) => void;
408+
type HookName = BasicHookName | ElementHookName | DocumentFragmentHookName | UponSanitizeElementHookName | UponSanitizeAttributeHookName;
409+
type NodeHook = (this: DOMPurify, currentNode: Node, hookEvent: null, config: Config) => void;
410+
type ElementHook = (this: DOMPurify, currentNode: Element, hookEvent: null, config: Config) => void;
411+
type DocumentFragmentHook = (this: DOMPurify, currentNode: DocumentFragment, hookEvent: null, config: Config) => void;
377412
type UponSanitizeElementHook = (this: DOMPurify, currentNode: Node, hookEvent: UponSanitizeElementHookEvent, config: Config) => void;
378-
type UponSanitizeAttributeHook = (this: DOMPurify, currentNode: Node, hookEvent: UponSanitizeAttributeHookEvent, config: Config) => void;
413+
type UponSanitizeAttributeHook = (this: DOMPurify, currentNode: Element, hookEvent: UponSanitizeAttributeHookEvent, config: Config) => void;
379414
interface UponSanitizeElementHookEvent {
380415
tagName: string;
381416
allowedTags: Record<string, boolean>;
@@ -396,4 +431,4 @@ type WindowLike = Pick<typeof globalThis, 'DocumentFragment' | 'HTMLTemplateElem
396431
trustedTypes?: typeof window.trustedTypes;
397432
};
398433

399-
export { type Config, type DOMPurify, type Hook, type HookName, type RemovedAttribute, type RemovedElement, type UponSanitizeAttributeHook, type UponSanitizeAttributeHookEvent, type UponSanitizeElementHook, type UponSanitizeElementHookEvent, type WindowLike, _default as default };
434+
export { type Config, type DOMPurify, type DocumentFragmentHook, type ElementHook, type HookName, type NodeHook, type RemovedAttribute, type RemovedElement, type UponSanitizeAttributeHook, type UponSanitizeAttributeHookEvent, type UponSanitizeElementHook, type UponSanitizeElementHookEvent, type WindowLike, _default as default };

0 commit comments

Comments
 (0)