Skip to content

Commit 86e342d

Browse files
committed
see #1121
fix: Changed how RETURN_TRUSTED_TYPE=false is being handled
1 parent adeebfa commit 86e342d

File tree

10 files changed

+26
-20
lines changed

10 files changed

+26
-20
lines changed

dist/purify.cjs.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ const getGlobal = function getGlobal() {
253253
* @return The policy created (or null, if Trusted Types
254254
* are not supported or creating the policy failed).
255255
*/
256-
const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
257-
if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
256+
const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement, config) {
257+
if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function' || config.RETURN_TRUSTED_TYPE === false) {
258258
return null;
259259
}
260260
// Allow the callers to control the unique policy name
@@ -649,7 +649,7 @@ function createDOMPurify() {
649649
} else {
650650
// Uninitialized policy, attempt to initialize the internal dompurify policy.
651651
if (trustedTypesPolicy === undefined) {
652-
trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
652+
trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript, cfg);
653653
}
654654
// If creating the internal policy succeeded sign internal variables.
655655
if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {

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

Lines changed: 3 additions & 3 deletions
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

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-lock.json

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/purify.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ const getGlobal = function (): WindowLike {
6262
*/
6363
const _createTrustedTypesPolicy = function (
6464
trustedTypes: TrustedTypePolicyFactory,
65-
purifyHostElement: HTMLScriptElement
65+
purifyHostElement: HTMLScriptElement,
66+
config: Config
6667
) {
6768
if (
6869
typeof trustedTypes !== 'object' ||
69-
typeof trustedTypes.createPolicy !== 'function'
70+
typeof trustedTypes.createPolicy !== 'function' ||
71+
config.RETURN_TRUSTED_TYPE === false
7072
) {
7173
return null;
7274
}
@@ -682,7 +684,8 @@ function createDOMPurify(window: WindowLike = getGlobal()): DOMPurify {
682684
if (trustedTypesPolicy === undefined) {
683685
trustedTypesPolicy = _createTrustedTypesPolicy(
684686
trustedTypes,
685-
currentScript
687+
currentScript,
688+
cfg
686689
);
687690
}
688691

0 commit comments

Comments
 (0)