Skip to content

Commit

Permalink
Fix blocked mailto in Chromium browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaifroid committed Jun 4, 2024
1 parent b76550d commit 91b8b93
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ function fetchUrlFromZIM (urlObjectOrString, range, expectedHeaders) {
var headers = new Headers();
if (contentLength !== null) headers.set('Content-Length', contentLength);
// Set Content-Security-Policy to sandbox the content (prevent XSS attacks from malicious ZIMs)
headers.set('Content-Security-Policy', "default-src 'self' data: file: blob: about: chrome-extension: bingmaps: https://pwa.kiwix.org https://kiwix.github.io 'unsafe-inline' 'unsafe-eval'; sandbox allow-scripts allow-same-origin allow-modals allow-popups allow-forms allow-downloads;");
headers.set('Content-Security-Policy', "default-src 'self' data: file: blob: about: mailto: chrome-extension: bingmaps: https://pwa.kiwix.org https://kiwix.github.io 'unsafe-inline' 'unsafe-eval'; sandbox allow-scripts allow-same-origin allow-modals allow-popups allow-forms allow-downloads;");
headers.set('Referrer-Policy', 'no-referrer');
if (contentType) headers.set('Content-Type', contentType);

Expand Down
2 changes: 1 addition & 1 deletion www/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: blob: file: about: chrome-extension: ms-appx-web: 'unsafe-inline' 'unsafe-eval';">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: blob: file: about: mailto: chrome-extension: ms-appx-web: 'unsafe-inline' 'unsafe-eval';">
<meta name="description" content="Placeholder for injecting an article into the iframe or window">
</head>
<body></body>
Expand Down
2 changes: 1 addition & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<title>Kiwix JS PWA</title>
<meta name="description" content="Offline Wikipedia reader">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' blob: data: file: about: https://download.kiwix.org https://*.download.kiwix.org https://pwa.kiwix.org https://kiwix.github.io https://api.github.com 'unsafe-inline' 'unsafe-eval'; frame-src 'self' moz-extension: chrome-extension:; object-src 'none';">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' blob: data: file: about: https://download.kiwix.org https://*.download.kiwix.org https://pwa.kiwix.org https://kiwix.github.io https://api.github.com 'unsafe-inline' 'unsafe-eval'; frame-src 'self' mailto: moz-extension: chrome-extension:; object-src 'none';">
<meta name="theme-color" content="black">
<!--
Kiwix (offline Wikipedia reader) - HTML5/Javascript version
Expand Down
2 changes: 1 addition & 1 deletion www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6189,7 +6189,7 @@ function displayArticleContentInContainer (dirEntry, htmlArticle) {
params.containsMathSVG = params.useMathJax ? /<img\s+(?=[^>]+?math-fallback-image)[^>]*?alt\s*=\s*['"][^'"]+[^>]+>/i.test(htmlArticle) : false;

// Add CSP to prevent external scripts and content - note that any existing CSP can only be hardened, not loosened
htmlArticle = htmlArticle.replace(/(<head\b[^>]*>)\s*/, '$1\n <meta http-equiv="Content-Security-Policy" content="default-src \'self\' data: file: blob: bingmaps: about: \'unsafe-inline\' \'unsafe-eval\';"></meta>\n ');
htmlArticle = htmlArticle.replace(/(<head\b[^>]*>)\s*/, '$1\n <meta http-equiv="Content-Security-Policy" content="default-src \'self\' data: file: blob: bingmaps: about: mailto: \'unsafe-inline\' \'unsafe-eval\';"></meta>\n ');

// Maker return links
uiUtil.makeReturnLink(dirEntry.getTitleOrUrl());
Expand Down
2 changes: 1 addition & 1 deletion www/topFrame.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: file: blob: about: 'unsafe-inline' 'unsafe-eval'; frame-src 'self' moz-extension: chrome-extension:; object-src 'none';">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: file: blob: about: 'unsafe-inline' 'unsafe-eval'; frame-src 'self' mailto: moz-extension: chrome-extension:; object-src 'none';">
<meta charset="utf-8"/>
<style>
html, body
Expand Down

0 comments on commit 91b8b93

Please sign in to comment.