Skip to content

Use Trusted Types in DOMPurify #5576

@sosnovsky

Description

@sosnovsky

I think it is also a good idea to update some of the few options for the DOMPurify configuration option to return trusted type by adding the RETURN_TRUSTED_TYPE property set to true when DOMPurify.sanitize() is used:

export declare function sanitize(source: string | Node, config: Config & { RETURN_DOM: true; }): HTMLElement;

Reference:
https://github.com/cure53/DOMPurify?tab=readme-ov-file#what-about-dompurify-and-trusted-types
https://web.dev/articles/trusted-types#use_a_library

Originally posted by @martgil in #5575 (review)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions