Skip to content

Commit 72c00db

Browse files
committed
Merge branch 'main' of github.com:cure53/DOMPurify
2 parents 49882dc + 2e5fd64 commit 72c00db

File tree

34 files changed

+234
-34
lines changed

34 files changed

+234
-34
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ jobs:
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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ DOMPurify is written in JavaScript and works in all modern browsers (Safari (10+
1010

1111
**Note that [DOMPurify v2.5.8](https://github.com/cure53/DOMPurify/releases/tag/2.5.8) is the latest version supporting MSIE. For important security updates compatible with MSIE, please use the [2.x branch](https://github.com/cure53/DOMPurify/tree/2.x).**
1212

13-
Our automated tests cover [28 different browsers](https://github.com/cure53/DOMPurify/blob/main/test/karma.custom-launchers.config.js#L5) right now, more to come. We also cover Node.js v17.x, v18.x, v19.x, v29.x, v21.x and v22.x, running DOMPurify on [jsdom](https://github.com/jsdom/jsdom). Older Node versions are known to work as well, but hey... no guarantees.
13+
Our automated tests cover [28 different browsers](https://github.com/cure53/DOMPurify/blob/main/test/karma.custom-launchers.config.js#L5) right now, more to come. We also cover Node.js v17.x, v18.x, v19.x, v20.x, v21.x and v22.x, running DOMPurify on [jsdom](https://github.com/jsdom/jsdom). Older Node versions are known to work as well, but hey... no guarantees.
1414

1515
DOMPurify is written by security people who have vast background in web attacks and XSS. Fear not. For more details please also read about our [Security Goals & Threat Model](https://github.com/cure53/DOMPurify/wiki/Security-Goals-&-Threat-Model). Please, read it. Like, really.
1616

dist/purify.cjs.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
/// <reference types="trusted-types" />
21
/*! @license DOMPurify 3.2.4 | (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.4/LICENSE */
32

3+
import { TrustedTypePolicy, TrustedHTML, TrustedTypesWindow } from 'trusted-types/lib';
4+
45
/**
56
* Configuration to control DOMPurify behavior.
67
*/
@@ -433,8 +434,7 @@ interface UponSanitizeAttributeHookEvent {
433434
type WindowLike = Pick<typeof globalThis, 'DocumentFragment' | 'HTMLTemplateElement' | 'Node' | 'Element' | 'NodeFilter' | 'NamedNodeMap' | 'HTMLFormElement' | 'DOMParser'> & {
434435
document?: Document;
435436
MozNamedAttrMap?: typeof window.NamedNodeMap;
436-
trustedTypes?: typeof window.trustedTypes;
437-
};
437+
} & Pick<TrustedTypesWindow, 'trustedTypes'>;
438438

439439
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 };
440440

dist/purify.cjs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/purify.es.d.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
/// <reference types="trusted-types" />
21
/*! @license DOMPurify 3.2.4 | (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.4/LICENSE */
32

3+
import { TrustedTypePolicy, TrustedHTML, TrustedTypesWindow } from 'trusted-types/lib';
4+
45
/**
56
* Configuration to control DOMPurify behavior.
67
*/
@@ -433,7 +434,6 @@ interface UponSanitizeAttributeHookEvent {
433434
type WindowLike = Pick<typeof globalThis, 'DocumentFragment' | 'HTMLTemplateElement' | 'Node' | 'Element' | 'NodeFilter' | 'NamedNodeMap' | 'HTMLFormElement' | 'DOMParser'> & {
434435
document?: Document;
435436
MozNamedAttrMap?: typeof window.NamedNodeMap;
436-
trustedTypes?: typeof window.trustedTypes;
437-
};
437+
} & Pick<TrustedTypesWindow, 'trustedTypes'>;
438438

439439
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 };

dist/purify.es.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/purify.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/purify.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"test:jsdom": "cross-env NODE_ENV=test BABEL_ENV=rollup node test/jsdom-node-runner --dot",
2020
"test:karma": "cross-env NODE_ENV=test BABEL_ENV=rollup karma start test/karma.conf.js --log-level warn ",
2121
"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": "cross-env NODE_ENV=test BABEL_ENV=rollup npm run lint && npm run test:jsdom && npm run test:karma -- --browsers Chrome",
23+
"verify-typescript": "node ./typescript/verify.js"
2324
},
2425
"main": "./dist/purify.cjs.js",
2526
"module": "./dist/purify.es.mjs",

scripts/fix-types.js

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const path = require('node:path');
77
// Note that this script is intended to run on the type declaration file that is
88
// output by Rollup, and not the type declaration file generated from TypeScript.
99
await fixCjsTypes(path.resolve(__dirname, '../dist/purify.cjs.d.ts'));
10-
await fixEsmTypes(path.resolve(__dirname, '../dist/purify.es.d.mts'));
1110
})().catch((ex) => {
1211
console.error(ex);
1312
process.exitCode = 1;
@@ -37,22 +36,5 @@ async function fixCjsTypes(fileName) {
3736
// for certain configurations, so add a `@ts-ignore` comment before it.
3837
fixed += '\n// @ts-ignore\nexport = _default;\n';
3938

40-
await fs.writeFile(fileName, addTrustedTypesReference(fixed));
41-
}
42-
43-
/**
44-
* Fixes the ESM type declarations file.
45-
* @param {string} fileName
46-
*/
47-
async function fixEsmTypes(fileName) {
48-
let types = await fs.readFile(fileName, { encoding: 'utf-8' });
49-
await fs.writeFile(fileName, addTrustedTypesReference(types));
50-
}
51-
52-
function addTrustedTypesReference(types) {
53-
// We need to tell TypeScript that we use the type declarations from
54-
// `trusted-types` so that it ends up in our type declaration type).
55-
// Without this, the references to trusted-types in the type declaration
56-
// file can cause compilation errors for certain configurations.
57-
return `/// <reference types="trusted-types" />\n${types}`;
39+
await fs.writeFile(fileName, fixed);
5840
}

0 commit comments

Comments
 (0)