Force-add CSP to document, to increase security

This commit is contained in:
Jaifroid 2023-03-10 11:46:58 +00:00
parent 018a553c21
commit db1fc67a9f

View File

@ -4751,10 +4751,10 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
// });
// }
// If there is no CSP, add one to prevent external scripts and content
if (!/<meta\b[^>]+Content-Security-Policy/i.test(htmlArticle)) {
// Add CSP to prevent external scripts and content - note that any existing CSP can only be hardened, not loosened
// if (!/<meta\b[^>]+Content-Security-Policy/i.test(htmlArticle)) {
htmlArticle = htmlArticle.replace(/(<head\b[^>]*>)\s*/, '$1\n <meta http-equiv="Content-Security-Policy" content="default-src \'self\' data: blob: bingmaps: about: \'unsafe-inline\' \'unsafe-eval\';"></meta>\n ');
}
// }
// Maker return links
uiUtil.makeReturnLink(dirEntry.getTitleOrUrl());