mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-01 04:50:59 +08:00
Add a restrictive CSP to the print window
This commit is contained in:
parent
0b0091aeb3
commit
740b51f9fa
2 changed files with 7 additions and 8 deletions
|
@ -9,6 +9,9 @@ export default class PrintWindow {
|
||||||
// This script will create the print prompt when loaded. We can also call
|
// This script will create the print prompt when loaded. We can also call
|
||||||
// print directly from this process, but inside print.js we can make sure to
|
// print directly from this process, but inside print.js we can make sure to
|
||||||
// call window.print() after we've cleaned up the dom for printing
|
// call window.print() after we've cleaned up the dom for printing
|
||||||
|
const tmp = app.getPath('temp');
|
||||||
|
const tmpMessagesPath = path.join(tmp, 'print.messages.js');
|
||||||
|
|
||||||
const scriptPath = path.join(__dirname, '..', 'static', 'print.js');
|
const scriptPath = path.join(__dirname, '..', 'static', 'print.js');
|
||||||
const stylesPath = path.join(__dirname, '..', 'static', 'print-styles.css');
|
const stylesPath = path.join(__dirname, '..', 'static', 'print-styles.css');
|
||||||
const participantsHtml = participants
|
const participantsHtml = participants
|
||||||
|
@ -20,6 +23,7 @@ export default class PrintWindow {
|
||||||
const content = `
|
const content = `
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<meta http-equiv="Content-Security-Policy" content="default-src * mailspring:; script-src 'self' chrome-extension://react-developer-tools; style-src * 'unsafe-inline' mailspring:; img-src * data: mailspring: file:;">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
${styleTags}
|
${styleTags}
|
||||||
<link rel="stylesheet" type="text/css" href="${stylesPath}">
|
<link rel="stylesheet" type="text/css" href="${stylesPath}">
|
||||||
|
@ -40,15 +44,13 @@ export default class PrintWindow {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
${htmlContent}
|
${htmlContent}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript" src="${tmpMessagesPath}"></script>
|
||||||
window.printMessages = ${printMessages}
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="${scriptPath}"></script>
|
<script type="text/javascript" src="${scriptPath}"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
this.tmpFile = path.join(app.getPath('temp'), 'print.html');
|
this.tmpFile = path.join(tmp, 'print.html');
|
||||||
this.browserWin = new BrowserWindow({
|
this.browserWin = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
|
@ -57,6 +59,7 @@ export default class PrintWindow {
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
fs.writeFileSync(tmpMessagesPath, `window.printMessages = ${printMessages}`);
|
||||||
fs.writeFileSync(this.tmpFile, content);
|
fs.writeFileSync(this.tmpFile, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,10 +48,6 @@ tutorial-tip-background.visible {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
|
||||||
background: #000;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tutorial-tip.visible:after {
|
.tutorial-tip.visible:after {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
Loading…
Reference in a new issue