Skip to content

Commit 0116b9b

Browse files
committed
fix: update SCRIPT_TAG_REGEX to tolerate end tags in script elements
1 parent 679b5d2 commit 0116b9b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

docs/scripts/generate-csp.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ const BUILD_DIR = fileURLToPath(new URL('../build', import.meta.url));
2626
// Anything else (e.g. application/ld+json structured data) is inert and needs no hash.
2727
const EXECUTABLE_SCRIPT_TYPES = new Set(['', 'module', 'text/javascript', 'application/javascript']);
2828

29-
const SCRIPT_TAG_REGEX = /<script\b([^>]*)>([\s\S]*?)<\/script>/gi;
29+
// `\b[^>]*` tolerates end tags like `</script >`, which browsers accept as terminating
30+
const SCRIPT_TAG_REGEX = /<script\b([^>]*)>([\s\S]*?)<\/script\b[^>]*>/gi;
3031

3132
function collectHtmlFiles(dir) {
3233
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {

0 commit comments

Comments
 (0)