diff --git a/src/runtime/nitro/plugins/30-cspSsgHashes.ts b/src/runtime/nitro/plugins/30-cspSsgHashes.ts
index 4fc09c88..98e785e4 100644
--- a/src/runtime/nitro/plugins/30-cspSsgHashes.ts
+++ b/src/runtime/nitro/plugins/30-cspSsgHashes.ts
@@ -4,8 +4,8 @@ import { generateHash } from '../../../utils/hash'
import type { Section } from '../../../types/module'
-const INLINE_SCRIPT_RE = /
diff --git a/test/fixtures/ssgHashes/pages/inline-style-with-linebreak.vue b/test/fixtures/ssgHashes/pages/inline-style-with-linebreak.vue
new file mode 100644
index 00000000..8393b55b
--- /dev/null
+++ b/test/fixtures/ssgHashes/pages/inline-style-with-linebreak.vue
@@ -0,0 +1,15 @@
+
+ Default page
+
+
diff --git a/test/ssgHashes.test.ts b/test/ssgHashes.test.ts
index 28fb35b1..b59f4c23 100644
--- a/test/ssgHashes.test.ts
+++ b/test/ssgHashes.test.ts
@@ -84,6 +84,23 @@ describe('[nuxt-security] SSG support of CSP', async () => {
expect(externalStyleHashes).toBe(expectedExternalStyleHashes)
})
+ it('sets script-src for inline scripts with line break', async () => {
+ const res = await fetch('/inline-script-with-linebreak')
+ const body = await res.text()
+ const { metaTag, csp, elementsWithIntegrity, inlineScriptHashes, externalScriptHashes, inlineStyleHashes, externalStyleHashes } = extractDataFromBody(body)
+
+ expect(res).toBeDefined()
+ expect(res).toBeTruthy()
+ expect(body).toBeDefined()
+ expect(metaTag).toBeDefined()
+ expect(csp).toBeDefined()
+ expect(elementsWithIntegrity).toBe(expectedIntegrityAttributes)
+ expect(inlineScriptHashes).toBe(expectedInlineScriptHashes + 1) // Inlined script in head
+ expect(externalScriptHashes).toBe(expectedExternalScriptHashes + 1) // + 1 vue modulepreload
+ expect(inlineStyleHashes).toBe(expectedInlineStyleHashes)
+ expect(externalStyleHashes).toBe(expectedExternalStyleHashes)
+ })
+
it('sets style-src for inline styles', async () => {
const res = await fetch('/inline-style')
@@ -102,6 +119,24 @@ describe('[nuxt-security] SSG support of CSP', async () => {
expect(externalStyleHashes).toBe(expectedExternalStyleHashes)
})
+ it('sets style-src for inline styles with line break', async () => {
+ const res = await fetch('/inline-style-with-linebreak')
+
+ const body = await res.text()
+ const { metaTag, csp, elementsWithIntegrity, inlineScriptHashes, externalScriptHashes, inlineStyleHashes, externalStyleHashes } = extractDataFromBody(body)
+
+ expect(res).toBeDefined()
+ expect(res).toBeTruthy()
+ expect(body).toBeDefined()
+ expect(metaTag).toBeDefined()
+ expect(csp).toBeDefined()
+ expect(elementsWithIntegrity).toBe(expectedIntegrityAttributes)
+ expect(inlineScriptHashes).toBe(expectedInlineScriptHashes)
+ expect(externalScriptHashes).toBe(expectedExternalScriptHashes + 1) // + 1 vue modulepreload
+ expect(inlineStyleHashes).toBe(expectedInlineStyleHashes + 1) // Inlined style
+ expect(externalStyleHashes).toBe(expectedExternalStyleHashes)
+ })
+
it('sets script-src for external scripts', async () => {
const res = await fetch('/external-script')