Skip to content

Commit 1c0423b

Browse files
authored
fix: do not add content-security-policy meta element if content is empty (#10026)
1 parent 86dd16c commit 1c0423b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.changeset/heavy-eels-wash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: do not add content-security-policy meta element if content is empty

packages/kit/src/runtime/server/page/csp.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,13 @@ class BaseProvider {
178178

179179
class CspProvider extends BaseProvider {
180180
get_meta() {
181-
const content = escape_html_attr(this.get_header(true));
182-
return `<meta http-equiv="content-security-policy" content=${content}>`;
181+
const content = this.get_header(true);
182+
183+
if (!content) {
184+
return;
185+
}
186+
187+
return `<meta http-equiv="content-security-policy" content=${escape_html_attr(content)}>`;
183188
}
184189
}
185190

0 commit comments

Comments
 (0)