Enables context isolation for loading window

This commit is contained in:
Josh Perez 2021-09-17 18:12:58 -04:00 committed by GitHub
parent ccfb9579ad
commit 6c906d5da8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 39 deletions

View File

@ -19,9 +19,8 @@
<span class="dot"></span> <span class="dot"></span>
<span class="dot"></span> <span class="dot"></span>
</div> </div>
<div class="message"></div> <div id="message"></div>
</div> </div>
<script type="text/javascript" src="js/components.js"></script>
<script type="text/javascript" src="ts/windows/loading/start.js"></script> <script type="text/javascript" src="ts/windows/loading/start.js"></script>
</body> </body>
</html> </html>

View File

@ -1340,7 +1340,7 @@ app.on('ready', async () => {
webPreferences: { webPreferences: {
...defaultWebPrefs, ...defaultWebPrefs,
nodeIntegration: false, nodeIntegration: false,
contextIsolation: false, contextIsolation: true,
preload: path.join(__dirname, 'ts', 'windows', 'loading', 'preload.js'), preload: path.join(__dirname, 'ts', 'windows', 'loading', 'preload.js'),
}, },
icon: windowIcon, icon: windowIcon,

View File

@ -14386,31 +14386,17 @@
"updated": "2021-09-15T21:07:50.995Z" "updated": "2021-09-15T21:07:50.995Z"
}, },
{ {
"rule": "jQuery-$(", "rule": "DOM-innerHTML",
"path": "ts/windows/loading/start.js", "path": "ts/windows/loading/start.js",
"line": "$(() => {", "line": " message.innerHTML = window.SignalWindow.i18n('optimizingApplication');",
"reasonCategory": "usageTrusted", "reasonCategory": "usageTrusted",
"updated": "2020-03-25T15:45:04.024Z" "updated": "2021-09-17T21:02:59.414Z"
}, },
{ {
"rule": "jQuery-$(", "rule": "DOM-innerHTML",
"path": "ts/windows/loading/start.js",
"line": " $('.message').text(window.i18n('optimizingApplication'));",
"reasonCategory": "usageTrusted",
"updated": "2021-07-22T03:00:34.561Z"
},
{
"rule": "jQuery-$(",
"path": "ts/windows/loading/start.ts", "path": "ts/windows/loading/start.ts",
"line": " $('.message').text(window.i18n('optimizingApplication'));", "line": " message.innerHTML = window.SignalWindow.i18n('optimizingApplication');",
"reasonCategory": "usageTrusted", "reasonCategory": "usageTrusted",
"updated": "2020-03-25T15:45:04.024Z" "updated": "2021-09-17T21:02:59.414Z"
},
{
"rule": "jQuery-$(",
"path": "ts/windows/loading/start.ts",
"line": "$(() => {",
"reasonCategory": "usageTrusted",
"updated": "2021-07-22T03:00:34.561Z"
} }
] ]

View File

@ -1,19 +1,11 @@
// Copyright 2020-2021 Signal Messenger, LLC // Copyright 2020-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
import { ipcRenderer } from 'electron'; import { contextBridge } from 'electron';
import * as url from 'url';
import * as i18n from '../../../js/modules/i18n';
import { strictAssert } from '../../util/assert';
const config = url.parse(window.location.toString(), true).query; // It is important to call this as early as possible
import '../context';
const { locale } = config; import { SignalWindow } from '../configure';
strictAssert(
typeof locale === 'string',
'Expected to be configured with a string locale'
);
const localeMessages = ipcRenderer.sendSync('locale-data'); contextBridge.exposeInMainWorld('SignalWindow', SignalWindow);
window.i18n = i18n.setup(locale, localeMessages);

View File

@ -1,6 +1,7 @@
// Copyright 2020-2021 Signal Messenger, LLC // Copyright 2020-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
$(() => { const message = document.getElementById('message');
$('.message').text(window.i18n('optimizingApplication')); if (message) {
}); message.innerHTML = window.SignalWindow.i18n('optimizingApplication');
}