Skip to content

Commit

Permalink
Fix the CSP regression (#280)
Browse files Browse the repository at this point in the history
* fix: csp

* fix: failing tests
  • Loading branch information
Skelmis authored Mar 30, 2024
1 parent d4f6e66 commit f6567af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion piccolo_api/csp/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def wrapped_send(message: Message):
if message["type"] == "http.response.start":
headers = message.get("headers", [])
header_value = bytes(
f"default-src: '{self.config.default_src}'", "utf8"
f"default-src '{self.config.default_src}'", "utf8"
)
if self.config.report_uri:
header_value = (
Expand Down
6 changes: 3 additions & 3 deletions tests/csp/test_csp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_headers(self):
# Make sure the headers got added:
self.assertEqual(
response.headers["content-security-policy"],
"default-src: 'self'",
"default-src 'self'",
)

# Make sure the original headers are still intact:
Expand All @@ -53,7 +53,7 @@ def test_default_src(self):

self.assertEqual(
response.headers.get("content-security-policy"),
"default-src: 'none'",
"default-src 'none'",
)

def test_report_uri(self):
Expand All @@ -66,5 +66,5 @@ def test_report_uri(self):

self.assertEqual(
response.headers["content-security-policy"],
"default-src: 'self'; report-uri foo.com",
"default-src 'self'; report-uri foo.com",
)

0 comments on commit f6567af

Please sign in to comment.