Skip to content

Commit

Permalink
fix csp *-src-elem
Browse files Browse the repository at this point in the history
  • Loading branch information
39zde committed Nov 14, 2024
1 parent 41ca2e8 commit 91245a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class UtilityFunctions {
if (!cssHash) {
throw new Error("Failed to update CSP for style-src");
}
html = html.replace(/(?<=style-src[\s\t]{1,})((?<directive>[\"\'][^\s]+[\"\'])[\s]{0,})+(?=\;)/gm, ` 'sha256-${cssHash}'`);
html = html.replace(/style-src[\s\t]{1,}((?<directive>[\"\'][^\s]+[\"\'])[\s]{0,})+(?=\;)/gm, `style-src-elem 'sha256-${cssHash}'`);

html = html.replace(sheet.ownerNode.outerHTML, `<style>${css}</style>`);
return html;
Expand Down Expand Up @@ -380,7 +380,7 @@ class UtilityFunctions {
throw new Error("Failed to update CSP for script-src");
}
// update the csp
html = html.replace(/(?<=script-src[\s\t]{1,})((?<directive>[\"\'][^\s]+[\"\'])[\s]{0,})+(?=\;)/gm, ` 'sha256-${jsHash}'`);
html = html.replace(/script-src[\s\t]{1,}((?<directive>[\"\'][^\s]+[\"\'])[\s]{0,})+(?=\;)/gm, `script-src-elem 'sha256-${jsHash}'`);
return html;
}
}
Expand Down

0 comments on commit 91245a3

Please sign in to comment.