Skip to content

Commit

Permalink
[17.0][FIX] fs_attachment: Add CSP header for fs stream
Browse files Browse the repository at this point in the history
  • Loading branch information
Fai committed Oct 31, 2024
1 parent 0a2f0bb commit b8eec32
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion fs_attachment/fs_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def read(self):
return f.read()
return super().read()

def get_response(self, as_attachment=None, immutable=None, **send_file_kwargs):
def get_response(self, as_attachment=None, immutable=None, content_security_policy="default-src 'none'", **send_file_kwargs):
if self.type != "fs":
return super().get_response(
as_attachment=as_attachment, immutable=immutable, **send_file_kwargs
Expand Down Expand Up @@ -79,6 +79,12 @@ def get_response(self, as_attachment=None, immutable=None, **send_file_kwargs):

if immutable and res.cache_control:
res.cache_control["immutable"] = None

res.headers['X-Content-Type-Options'] = 'nosniff'

if content_security_policy:
res.headers['Content-Security-Policy'] = content_security_policy

return res

@classmethod
Expand Down

0 comments on commit b8eec32

Please sign in to comment.