Skip to content

Commit 4d1de12

Browse files
committed
Merge remote-tracking branch 'origin/main' into 3.x
2 parents 3990b7e + c4a081d commit 4d1de12

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1472
-777
lines changed

.github/workflows/build-and-test.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ jobs:
1818

1919
strategy:
2020
matrix:
21-
node-version: [16.x, 17.x, 18.x, 19.x, 20.x, 21.x]
21+
node-version: [18.x, 19.x, 20.x, 21.x, 22.x, 23.x]
2222

2323
steps:
2424
- name: Checkout
25-
uses: actions/checkout@v4
25+
uses: actions/checkout@v5
2626
- name: Setup Node.js ${{ matrix.node-version }}
27-
uses: actions/setup-node@v4
27+
uses: actions/setup-node@v5
2828
with:
2929
node-version: ${{ matrix.node-version }}
3030
cache: 'npm'
@@ -35,11 +35,13 @@ jobs:
3535
- name: Lint
3636
run: npm run lint
3737
- name: Test
38-
uses: GabrielBB/xvfb-action@v1.6
38+
uses: GabrielBB/xvfb-action@v1.7
3939
with:
4040
run: npm run test:ci
4141
env:
42-
TEST_BROWSERSTACK: ${{ startsWith(matrix.node-version, '21') }}
42+
TEST_BROWSERSTACK: ${{ startsWith(matrix.node-version, '22') }}
4343
TEST_PROBE_ONLY: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/2.x' }}
4444
BS_USERNAME: ${{ secrets.BS_USERNAME }}
4545
BS_ACCESSKEY: ${{ secrets.BS_ACCESSKEY }}
46+
- name: Verify TypeScript
47+
run: npm run verify-typescript

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
steps:
2727
- name: Checkout repository
28-
uses: actions/checkout@v4
28+
uses: actions/checkout@v5
2929
with:
3030
# We must fetch at least the immediate parents so that if this is
3131
# a pull request then we can checkout the head.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
DOMPurify
2-
Copyright 2024 Dr.-Ing. Mario Heiderich, Cure53
2+
Copyright 2025 Dr.-Ing. Mario Heiderich, Cure53
33

44
DOMPurify is free software; you can redistribute it and/or modify it under the
55
terms of either:

README.md

Lines changed: 53 additions & 15 deletions
Large diffs are not rendered by default.

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dompurify",
3-
"version": "3.2.2",
3+
"version": "3.3.0",
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

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
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 */
1+
/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */
2+
3+
import { TrustedTypePolicy, TrustedHTML, TrustedTypesWindow } from 'trusted-types/lib';
34

45
/**
56
* Configuration to control DOMPurify behavior.
67
*/
78
interface Config {
89
/**
910
* Extend the existing array of allowed attributes.
11+
* Can be an array of attribute names, or a function that receives
12+
* the attribute name and tag name to determine if the attribute is allowed.
1013
*/
11-
ADD_ATTR?: string[] | undefined;
14+
ADD_ATTR?: string[] | ((attributeName: string, tagName: string) => boolean) | undefined;
1215
/**
1316
* Extend the existing array of elements that can use Data URIs.
1417
*/
1518
ADD_DATA_URI_TAGS?: string[] | undefined;
1619
/**
1720
* Extend the existing array of allowed tags.
21+
* Can be an array of tag names, or a function that receives
22+
* the tag name to determine if the tag is allowed.
1823
*/
19-
ADD_TAGS?: string[] | undefined;
24+
ADD_TAGS?: string[] | ((tagName: string) => boolean) | undefined;
2025
/**
2126
* Extend the existing array of elements that are safe for URI-like values (be careful, XSS risk).
2227
*/
@@ -75,7 +80,7 @@ interface Config {
7580
* Regular expression or function to match to allowed attributes.
7681
* Default is null (disallow any attributes not on the allow list).
7782
*/
78-
attributeNameCheck?: RegExp | ((attributeName: string) => boolean) | null | undefined;
83+
attributeNameCheck?: RegExp | ((attributeName: string, tagName?: string) => boolean) | null | undefined;
7984
/**
8085
* Allow custom elements derived from built-ins if they pass `tagNameCheck`. Default is false.
8186
*/
@@ -329,44 +334,49 @@ interface DOMPurify {
329334
addHook(entryPoint: 'uponSanitizeAttribute', hookFunction: UponSanitizeAttributeHook): void;
330335
/**
331336
* Remove a DOMPurify hook at a given entryPoint
332-
* (pops it from the stack of hooks if more are present)
337+
* (pops it from the stack of hooks if hook not specified)
333338
*
334339
* @param entryPoint entry point for the hook to remove
335-
* @returns removed(popped) hook
340+
* @param hookFunction optional specific hook to remove
341+
* @returns removed hook
336342
*/
337-
removeHook(entryPoint: BasicHookName): NodeHook | undefined;
343+
removeHook(entryPoint: BasicHookName, hookFunction?: NodeHook): NodeHook | undefined;
338344
/**
339345
* Remove a DOMPurify hook at a given entryPoint
340-
* (pops it from the stack of hooks if more are present)
346+
* (pops it from the stack of hooks if hook not specified)
341347
*
342348
* @param entryPoint entry point for the hook to remove
343-
* @returns removed(popped) hook
349+
* @param hookFunction optional specific hook to remove
350+
* @returns removed hook
344351
*/
345-
removeHook(entryPoint: ElementHookName): ElementHook | undefined;
352+
removeHook(entryPoint: ElementHookName, hookFunction?: ElementHook): ElementHook | undefined;
346353
/**
347354
* Remove a DOMPurify hook at a given entryPoint
348-
* (pops it from the stack of hooks if more are present)
355+
* (pops it from the stack of hooks if hook not specified)
349356
*
350357
* @param entryPoint entry point for the hook to remove
351-
* @returns removed(popped) hook
358+
* @param hookFunction optional specific hook to remove
359+
* @returns removed hook
352360
*/
353-
removeHook(entryPoint: DocumentFragmentHookName): DocumentFragmentHook | undefined;
361+
removeHook(entryPoint: DocumentFragmentHookName, hookFunction?: DocumentFragmentHook): DocumentFragmentHook | undefined;
354362
/**
355363
* Remove a DOMPurify hook at a given entryPoint
356-
* (pops it from the stack of hooks if more are present)
364+
* (pops it from the stack of hooks if hook not specified)
357365
*
358366
* @param entryPoint entry point for the hook to remove
359-
* @returns removed(popped) hook
367+
* @param hookFunction optional specific hook to remove
368+
* @returns removed hook
360369
*/
361-
removeHook(entryPoint: 'uponSanitizeElement'): UponSanitizeElementHook | undefined;
370+
removeHook(entryPoint: 'uponSanitizeElement', hookFunction?: UponSanitizeElementHook): UponSanitizeElementHook | undefined;
362371
/**
363372
* Remove a DOMPurify hook at a given entryPoint
364-
* (pops it from the stack of hooks if more are present)
373+
* (pops it from the stack of hooks if hook not specified)
365374
*
366375
* @param entryPoint entry point for the hook to remove
367-
* @returns removed(popped) hook
376+
* @param hookFunction optional specific hook to remove
377+
* @returns removed hook
368378
*/
369-
removeHook(entryPoint: 'uponSanitizeAttribute'): UponSanitizeAttributeHook | undefined;
379+
removeHook(entryPoint: 'uponSanitizeAttribute', hookFunction?: UponSanitizeAttributeHook): UponSanitizeAttributeHook | undefined;
370380
/**
371381
* Removes all DOMPurify hooks at a given entryPoint
372382
*
@@ -428,8 +438,7 @@ interface UponSanitizeAttributeHookEvent {
428438
type WindowLike = Pick<typeof globalThis, 'DocumentFragment' | 'HTMLTemplateElement' | 'Node' | 'Element' | 'NodeFilter' | 'NamedNodeMap' | 'HTMLFormElement' | 'DOMParser'> & {
429439
document?: Document;
430440
MozNamedAttrMap?: typeof window.NamedNodeMap;
431-
trustedTypes?: typeof window.trustedTypes;
432-
};
441+
} & Pick<TrustedTypesWindow, 'trustedTypes'>;
433442

434443
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 };
435444

0 commit comments

Comments
 (0)