Skip to content

Commit

Permalink
#5569 Add compliance with Trusted Types (#5575)
Browse files Browse the repository at this point in the history
* #5569 Add temporary fix for trusted types

* fix tests

* fix print page

* update purify.d.ts
  • Loading branch information
sosnovsky authored Jan 24, 2024
1 parent a403966 commit 7dbae7d
Show file tree
Hide file tree
Showing 42 changed files with 322 additions and 397 deletions.
1 change: 1 addition & 0 deletions extension/chrome/dev/ci_unit_test.htm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<h1 id="h1">loading..</h1>
<p>running..</p>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/openpgp.js"></script>
<script src="/lib/jquery.min.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/dev/export.htm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<body id="settings">
<pre style="text-align: left; font-family: monospace"></pre>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/elements/add_pubkey.htm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ <h1>Add a public key to email address</h1>
<div id="fineuploader" class="display_none"></div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/elements/attachment.htm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
</div>
<div id="name" data-test="attachment-name"></div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/elements/attachment_preview.htm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

<div id="attachment-preview-container"></div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/elements/backup.htm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/elements/compose.htm
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ <h1 id="header_title" data-test="header-title">New Secure Message</h1>
<div id="attachments" data-test="replied-attachments"></div>
</div>
</div>
<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/openpgp.js"></script>
<script src="/lib/jquery.min.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion extension/chrome/elements/oauth2.htm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<title>OAuth 2.0 Finish Page</title>
Expand Down
3 changes: 2 additions & 1 deletion extension/chrome/elements/passphrase.htm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- © 2016-2018 FlowCrypt Limited. Limitations apply. Contact [email protected] -->

<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
Expand Down Expand Up @@ -45,6 +45,7 @@ <h1 class="passphrase_text" data-test="passphrase-text"></h1>
>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/elements/pgp_block.htm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<div id="pgp_block" data-test="pgp-block-content">Loading...</div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/openpgp.js"></script>
<script src="/lib/jquery.min.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class PgpBlockViewPrintModule {
return;
}
const w = window.open();
const html = `
let html = `
<!DOCTYPE html>
<html lang="en-us">
<head>
Expand Down Expand Up @@ -81,6 +81,12 @@ export class PgpBlockViewPrintModule {
</body>
</html>
`;
if (w?.trustedTypes && w?.trustedTypes.createPolicy) {
const policy = w?.trustedTypes.createPolicy('print-policy', {
createHTML: (string: string) => string,
});
html = policy.createHTML(html);
}
w?.document.write(html);
// Give some time for above dom to load in print dialog
// https://stackoverflow.com/questions/31725373/google-chrome-not-showing-image-in-print-preview
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/elements/pgp_pubkey.htm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<pre class="pubkey hide_if_compact"></pre>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/popups/default.htm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/popups/select_account.htm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<a href="#" class="action_add_account">Add Account</a>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/fatal.htm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<div class="details">loading details..</div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/inbox/inbox.htm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ <h1></h1>
</tr>
</table>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ <h1 class="text-center">FlowCrypt Settings</h1>
</div>
</section>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/initial.htm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
</div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="initial.js" type="module"></script>
</body>
Expand Down
8 changes: 4 additions & 4 deletions extension/chrome/settings/initial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { View } from '../../js/common/view.js';
View.run(
class InitialView extends View {
public render = async () => {
if (Catch.browser().name === 'chrome' && Number(Catch.browser().v) >= 76) {
$('#chrome-steps').css('display', 'block');
} else {
$('#firefox-steps').css('display', 'block');
const browserName = Catch.browser().name === 'chrome' && Number(Catch.browser().v) >= 76 ? 'chrome' : 'firefox';
const stepsEl = document.getElementById(`${browserName}-steps`);
if (stepsEl) {
stepsEl.style.display = 'block';
}
};

Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/modules/add_key.htm
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ <h1>Add Private Key <span id="spinner_container"></span></h1>
<div id="compatibility_fix" class="compatibility_fix_container"></div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/fine-uploader.js"></script>
<script src="/lib/jquery.min.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/modules/backup.htm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<body id="settings" data-test="container-backup-dialog">
<div id="backup-template-container"></div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/modules/change_passphrase.htm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
</div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/modules/compatibility.htm
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ <h1>OpenPGP key compatibility test</h1>
</div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/modules/contacts.htm
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ <h1></h1>
</div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/modules/debug_api.htm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<p>This page is meant for debugging purposes. If you have questions, please email [email protected]</p>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/modules/decrypt.htm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ <h1>Decrypt a file</h1>
</div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/modules/experimental.htm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ <h1>Experimental functionality</h1>
<div class="line">
<a href="#" class="action_reset_account bad" data-test="action-reset-account">Reset <span class="email"></span> and set it up again</a>
</div>
<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/modules/help.htm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ <h2>Send message to FlowCrypt developers</h2>
</div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/modules/keyserver.htm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ <h1>Let others encrypt for you easier</h1>
<div class="line summary"></div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/modules/my_key.htm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
</div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/modules/my_key_update.htm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
</div>
<div id="compatibility_fix" class="compatibility_fix_container"></div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/fine-uploader.js"></script>
<script src="/lib/jquery.min.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/modules/my_key_user_ids.htm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<div class="line"><a href="#" class="action_show_public_key">Back to Public Key</a></div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/modules/security.htm
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ <h3>Password protected messages</h3>
</p> -->
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/modules/test_passphrase.htm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<div class="line">Cannot remember? <a href="#" class="action_change_passphrase">Change your pass phrase</a></div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/sweetalert2.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/chrome/settings/setup.htm
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ <h1>Set Up FlowCrypt</h1>
</div>
</div>

<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/fine-uploader.js"></script>
<script src="/lib/jquery.min.js"></script>
Expand Down
1 change: 1 addition & 0 deletions extension/js/background_page/background_page.htm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
</head>

<body>
<script src="/lib/trusted-types.js"></script>
<script src="/lib/purify.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/openpgp.js"></script>
Expand Down
Loading

0 comments on commit 7dbae7d

Please sign in to comment.