mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-25 02:57:22 +00:00
Correct CSP
no need blob: value for object-src
This commit is contained in:
parent
ed22209e6c
commit
beb619c2c2
@ -82,16 +82,16 @@ except ImportError:
|
|||||||
def add_security_headers(resp):
|
def add_security_headers(resp):
|
||||||
csp = "default-src 'self'"
|
csp = "default-src 'self'"
|
||||||
csp += ''.join([' ' + host for host in config.config_trustedhosts.strip().split(',')])
|
csp += ''.join([' ' + host for host in config.config_trustedhosts.strip().split(',')])
|
||||||
csp += " 'unsafe-inline' 'unsafe-eval'; font-src 'self' data:; img-src 'self' blob:"
|
csp += " 'unsafe-inline' 'unsafe-eval'; font-src 'self' data:; img-src 'self'"
|
||||||
if request.path.startswith("/author/") and config.config_use_goodreads:
|
if request.path.startswith("/author/") and config.config_use_goodreads:
|
||||||
csp += " images.gr-assets.com i.gr-assets.com s.gr-assets.com"
|
csp += " images.gr-assets.com i.gr-assets.com s.gr-assets.com"
|
||||||
csp += " data:;"
|
csp += " blob: data:;"
|
||||||
csp += " object-src 'none'"
|
csp += " object-src 'none';"
|
||||||
resp.headers['Content-Security-Policy'] = csp
|
resp.headers['Content-Security-Policy'] = csp
|
||||||
if request.endpoint == "edit-book.show_edit_book" or config.config_use_google_drive:
|
if request.endpoint == "edit-book.show_edit_book" or config.config_use_google_drive:
|
||||||
resp.headers['Content-Security-Policy'] += " *"
|
resp.headers['Content-Security-Policy'] += " *"
|
||||||
elif request.endpoint == "web.read_book":
|
elif request.endpoint == "web.read_book":
|
||||||
resp.headers['Content-Security-Policy'] += " blob:; style-src-elem 'self' blob: 'unsafe-inline';"
|
resp.headers['Content-Security-Policy'] += " style-src-elem 'self' blob: 'unsafe-inline';"
|
||||||
resp.headers['X-Content-Type-Options'] = 'nosniff'
|
resp.headers['X-Content-Type-Options'] = 'nosniff'
|
||||||
resp.headers['X-Frame-Options'] = 'SAMEORIGIN'
|
resp.headers['X-Frame-Options'] = 'SAMEORIGIN'
|
||||||
resp.headers['X-XSS-Protection'] = '1; mode=block'
|
resp.headers['X-XSS-Protection'] = '1; mode=block'
|
||||||
|
Loading…
Reference in New Issue
Block a user