You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
We're trying to implement Trusted types CSP in our Web Application (which uses OverlayScrollbars) and we're hitting an issue due to the unsafe assignment on
Describe the solution you'd like
For fixing it, you can create a custom policy that only allows that values that are set within the library. Something like
let overlayScrollbarsTrustedTypesPolicy: Pick<TrustedTypePolicy, 'createHTML'> | undefined;
if (window.trustedTypes) {
overlayScrollbarsTrustedTypesPolicy= window.trustedTypes.createPolicy(
'overlayScrollbarsTrustedTypesPolicy',
{
createHTML: (url: string) => {
if (
url === '<div class=\"os-environment\"><div></div></div>'
) {
return url;
}
// The URL is not allowed, return an empty string
return '';
},
}
);
}
export { iFrameDocumentTrustedTypesPolicy };
And then apply the policy in the location we're getting the issue
export const createDOM = (html: string): ReadonlyArray<Node> => {
const createdDiv = createDiv();
createdDiv.innerHTML =
(overlayScrollbarsTrustedTypesPolicy?.createHTML(html.trim()) as unknown as string) ?? html.trim();
return each(contents(createdDiv), elm => removeElements(elm));
};
The text was updated successfully, but these errors were encountered:
Thanks for the suggestion! I'll definitely add something like this, probably the design will look something like the current OverlayScrollbars.nonce api. With the naming of OverlayScrollbars.trustedTypesPolicy(newTurstedTypePolicy)
I'll look into the trusted types api first though as I'm not very familiar with it yet and TypeScript doesn't offer any types.
Is your feature request related to a problem? Please describe.
We're trying to implement Trusted types CSP in our Web Application (which uses OverlayScrollbars) and we're hitting an issue due to the unsafe assignment on
OverlayScrollbars/packages/overlayscrollbars/src/support/dom/create.ts
Line 21 in 998cc58
You can find more details here:
https://web.dev/articles/trusted-types
Describe the solution you'd like
For fixing it, you can create a custom policy that only allows that values that are set within the library. Something like
And then apply the policy in the location we're getting the issue
The text was updated successfully, but these errors were encountered: