Skip to content

Commit

Permalink
fix: do not add content-security-policy meta element if content is em…
Browse files Browse the repository at this point in the history
…pty (#10026)
  • Loading branch information
GitRowin authored May 26, 2023
1 parent 86dd16c commit 1c0423b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-eels-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: do not add content-security-policy meta element if content is empty
9 changes: 7 additions & 2 deletions packages/kit/src/runtime/server/page/csp.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,13 @@ class BaseProvider {

class CspProvider extends BaseProvider {
get_meta() {
const content = escape_html_attr(this.get_header(true));
return `<meta http-equiv="content-security-policy" content=${content}>`;
const content = this.get_header(true);

if (!content) {
return;
}

return `<meta http-equiv="content-security-policy" content=${escape_html_attr(content)}>`;
}
}

Expand Down

0 comments on commit 1c0423b

Please sign in to comment.