1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-10-18 08:35:54 +00:00

Make light theme default theme on epub reader

Fix csp Header for reader and google drive (#3108)
Testrun
This commit is contained in:
Ozzie Isaacs 2024-07-25 21:41:40 +02:00
parent a0728b07d0
commit f8adcbb691
4 changed files with 667 additions and 440 deletions

View File

@ -463,8 +463,8 @@ def rename_author_path(first_author, old_author_dir, renamed_author, calibre_pat
except OSError as ex: except OSError as ex:
log.error("Rename author from: %s to %s: %s", old_author_path, new_author_path, ex) log.error("Rename author from: %s to %s: %s", old_author_path, new_author_path, ex)
log.debug(ex, exc_info=True) log.debug(ex, exc_info=True)
return _("Rename author from: '%(src)s' to '%(dest)s' failed with error: %(error)s", raise Exception(_("Rename author from: '%(src)s' to '%(dest)s' failed with error: %(error)s",
src=old_author_path, dest=new_author_path, error=str(ex)) src=old_author_path, dest=new_author_path, error=str(ex)))
return new_authordir return new_authordir
# Moves files in file storage during author/title rename, or from temp dir to file storage # Moves files in file storage during author/title rename, or from temp dir to file storage

View File

@ -79,6 +79,6 @@ var reader;
} }
// Default settings load // Default settings load
const theme = localStorage.getItem("calibre.reader.theme") ?? Object.keys(themes)[0]; const theme = localStorage.getItem("calibre.reader.theme") ?? "lightTheme";
selectTheme(theme); selectTheme(theme);
})(); })();

View File

@ -89,8 +89,10 @@ except ImportError:
def add_security_headers(resp): def add_security_headers(resp):
default_src = ([host.strip() for host in config.config_trustedhosts.split(',') if host] + default_src = ([host.strip() for host in config.config_trustedhosts.split(',') if host] +
["'self'", "'unsafe-inline'", "'unsafe-eval'"]) ["'self'", "'unsafe-inline'", "'unsafe-eval'"])
csp = "default-src " + ' '.join(default_src) + "; " csp = "default-src " + ' '.join(default_src)
csp += "font-src 'self' data:" if request.endpoint == "web.read_book" and config.config_use_google_drive:
csp +=" blob: "
csp += "; font-src 'self' data:"
if request.endpoint == "web.read_book": if request.endpoint == "web.read_book":
csp += " blob: " csp += " blob: "
csp += "; img-src 'self'" csp += "; img-src 'self'"
@ -98,12 +100,10 @@ def add_security_headers(resp):
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 += " data:"
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:
csp += " *;" csp += " *"
elif request.endpoint == "web.read_book": if request.endpoint == "web.read_book":
csp += " blob:; style-src-elem 'self' blob: 'unsafe-inline';" csp += " blob: ; style-src-elem 'self' blob: 'unsafe-inline'"
else: csp += "; object-src 'none';"
csp += ";"
csp += " object-src 'none';"
resp.headers['Content-Security-Policy'] = csp resp.headers['Content-Security-Policy'] = csp
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'

File diff suppressed because it is too large Load Diff