Bug 1603809 - Follow-up, don't access OpenPGP items if disabled at build time. r=mkmelin DONTBUILD
authorKai Engert <kaie@kuix.de>
Tue, 24 Mar 2020 10:31:23 +0100
changeset 29067 8580c41d5e5a5243ada9a02d4e42748d7fdc295f
parent 29066 8ca637b203363896d542f8921f82a0afb8139d8e
child 29068 07d338a8bb4491b7ee667e87519c7eb40e45dfdd
push id17185
push userkaie@kuix.de
push dateWed, 25 Mar 2020 17:26:04 +0000
treeherdercomm-central@07d338a8bb44 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1603809
Bug 1603809 - Follow-up, don't access OpenPGP items if disabled at build time. r=mkmelin DONTBUILD
mail/extensions/am-e2e/am-e2e.js
--- a/mail/extensions/am-e2e/am-e2e.js
+++ b/mail/extensions/am-e2e/am-e2e.js
@@ -79,17 +79,19 @@ function e2eInitializeFields() {
     gEncryptionCertName.value = "";
     gEncryptionCertName.displayName = "";
     gEncryptionCertName.dbKey = "";
 
     gSignCertName.value = "";
     gSignCertName.displayName = "";
     gSignCertName.dbKey = "";
 
-    gKeyId.value = "";
+    if (MailConstants.MOZ_OPENPGP) {
+      gKeyId.value = "";
+    }
 
     gRequireEncrypt.disabled = true;
     gDoNotEncrypt.disabled = true;
     gSignMessages.disabled = true;
 
     gSignMessages.checked = false;
     gEncryptionChoices.value = 0;
     if (MailConstants.MOZ_OPENPGP) {
@@ -123,17 +125,21 @@ function e2eInitializeFields() {
       }
     } catch (e) {}
 
     gEncryptionChoices.value = gIdentity.getIntAttribute("encryptionpolicy");
     if (MailConstants.MOZ_OPENPGP) {
       gTechChoices.value = gIdentity.getIntAttribute("e2etechpref");
     }
 
-    let enableEnc = gEncryptionCertName.value || gKeyId.value;
+    let enableEnc = !!gEncryptionCertName.value;
+    if (MailConstants.MOZ_OPENPGP) {
+      enableEnc = enableEnc || !!gKeyId.value;
+    }
+
     gRequireEncrypt.disabled = !enableEnc;
     gDoNotEncrypt.disabled = !enableEnc;
     enableEncryptionControls(enableEnc);
 
     gSignCertName.value = gIdentity.getUnicharAttribute("signing_cert_name");
     gSignCertName.dbKey = gIdentity.getCharAttribute("signing_cert_dbkey");
     x509cert = null;
     // same procedure as with gEncryptionCertName (see above)
@@ -146,17 +152,21 @@ function e2eInitializeFields() {
         gSignCertName.value =
           x509cert.displayName + " [" + x509cert.serialNumber + "]";
         gSignCertName.displayName = x509cert.displayName;
       }
     } catch (e) {}
 
     gSignMessages.checked = gIdentity.getBoolAttribute("sign_mail");
 
-    let enableSig = gSignCertName.value || gKeyId.value;
+    let enableSig = gSignCertName.value;
+    if (MailConstants.MOZ_OPENPGP) {
+      enableSig = enableSig || !!gKeyId.value;
+    }
+
     gSignMessages.disabled = !enableSig;
     enableSigningControls(enableSig);
   }
 
   // Always start with enabling select buttons.
   // This will keep the visibility of buttons in a sane state as user
   // jumps from security panel of one account to another.
   enableSelectButtons();
@@ -485,17 +495,20 @@ function smimeClearCert(smime_cert) {
     return;
   }
 
   certInfo.disabled = true;
   certInfo.value = "";
   certInfo.displayName = "";
   certInfo.dbKey = "";
 
-  let stillHaveOther = gKeyId && gKeyId.value;
+  let stillHaveOther = false;
+  if (MailConstants.MOZ_OPENPGP) {
+    stillHaveOther = gKeyId && gKeyId.value;
+  }
 
   if (!stillHaveOther) {
     if (smime_cert == kEncryptionCertPref) {
       enableEncryptionControls(false);
     } else if (smime_cert == kSigningCertPref) {
       enableSigningControls(false);
     }
   }