Review security and fix some security bugs add some features to TODO.md

This commit is contained in:
2026-10-08 18:52:22 +03:00
parent 9adbce6a32
commit e34f3dc911
8 changed files with 91 additions and 12 deletions
+10 -2
View File
@@ -140,7 +140,8 @@ if (typeof showCompose === 'function') {
const encrypt = $('#pgp-encrypt');
const sign = $('#pgp-sign');
if (reply?.encrypted) { encrypt.checked = true; sign.checked = true; touched = true; }
encrypt.addEventListener('change', () => { touched = true; });
if (touched) encrypt.dataset.touched = '1';
encrypt.addEventListener('change', () => { touched = true; encrypt.dataset.touched = '1'; });
let timer = null;
const refresh = async () => {
const to = $('#compose-to')?.value || '';
@@ -170,8 +171,15 @@ window.pgpPrepareSend = async function pgpPrepareSend(to, cc) {
if (!pgpApi()) return null;
let encrypt = Boolean($('#pgp-encrypt')?.checked);
const sign = Boolean($('#pgp-sign')?.checked);
if (!encrypt && !sign) return null;
if (!encrypt && !sign && $('#pgp-encrypt')?.dataset.touched === '1') return null;
const status = await pgpApi().checkSend({ to, cc, sign });
// The default-on update is debounced, so a quick send could skip encryption even though keys exist.
if (!encrypt && !status.missing.length && status.recipients.length && $('#pgp-encrypt')?.dataset.touched !== '1') {
if (confirm('Public keys are available for all recipients.\n\nSend this message WITHOUT encryption?')) {
if (!sign) return null;
} else return false;
}
if (!encrypt && !sign) return null;
if (encrypt && status.missing.length) {
const sendPlain = confirm(`No public key for ${status.missing.join(', ')}.\n\nThe message cannot be encrypted for everyone. Send it WITHOUT encryption?`);
if (!sendPlain) return false;