Commit 7fbae3e5 authored by Nico Josuttis's avatar Nico Josuttis

try to find valid keys inside enigmail

parent 744fb1d3
......@@ -475,6 +475,7 @@ Enigmail.hlp = {
*/
getInvalidAddress: function (gpgMsg)
{
EnigmailCommon.DEBUG_LOG("enigmailMsgComposeHelper.js: getInvalidAddress(): gpgMsg=\""+gpgMsg+"\"\n\n");
var invalidAddr = [];
var lines = gpgMsg.split(/[\n\r]+/);
for (var i=0; i < lines.length; i++) {
......
......@@ -1050,9 +1050,9 @@ Enigmail.msg = {
}
// if allowed, try to send automatically if all keys known
if (toAddrList.length > 0 && this.encryptRules == 1) {
var keyList = Enigmail.hlp.validKeysForAllRecipients(toAddrList.join(", "),
false); // don't refresh key list
if (keyList != null) {
var validKeyList = Enigmail.hlp.validKeysForAllRecipients(toAddrList.join(", "),
false); // don't refresh key list
if (validKeyList != null) {
this.encryptRules = 2;
}
}
......@@ -1301,6 +1301,9 @@ Enigmail.msg = {
if (!result) {
return null;
}
if (result.toAddr) {
toAddr = result.toAddr;
}
if (result.doRulesProcessingAgain) { // start rule processing again ?
doRulesProcessingAgain=true;
forceRecipientSettings=true;
......@@ -1315,6 +1318,7 @@ Enigmail.msg = {
}
}
EnigmailCommon.DEBUG_LOG("enigmailMsgComposeOverlay.js: Enigmail.msg.keySelection(): return toAddr=\""+toAddr+"\" bccAddr=\""+bccAddr+"\"\n");
return {
sendFlags: sendFlags,
toAddr: toAddr,
......@@ -1410,10 +1414,10 @@ Enigmail.msg = {
// if allowed, try to send automatically if all keys known
if (((sendFlags&ENCRYPT) == 0) && (!flagsObj.value || flagsObj.encrypt == 1) && bccAddr.length == 0) {
var keyList = Enigmail.hlp.validKeysForAllRecipients(toAddr,
true); // refresh key list
if (keyList != null) {
toAddr = keyList.join(", ");
var validKeyList = Enigmail.hlp.validKeysForAllRecipients(toAddr,
true); // refresh key list
if (validKeyList != null) {
toAddr = validKeyList.join(", ");
sendFlags |= ENCRYPT;
}
}
......@@ -1451,11 +1455,22 @@ Enigmail.msg = {
var testStatusFlagsObj = new Object();
var testErrorMsgObj = new Object();
// get keys for remaining email addresses
// - NOTE: This should not be necessary; however, in GPG there is a problem:
// Only the first key found for an email is used.
// If this is invalid, no other keys are tested.
// Thus, WE make it better here in enigmail until the bug is fixed.
var validKeyList = Enigmail.hlp.validKeysForAllRecipients(toAddr,
true); // refresh key list
if (validKeyList != null) {
toAddr = validKeyList.join(", ");
}
// encrypt test message for test recipients
var testPlain = "Test Message";
var testUiFlags = nsIEnigmail.UI_TEST;
var testSendFlags = nsIEnigmail.SEND_TEST | ENCRYPT | optSendFlags ;
EnigmailCommon.DEBUG_LOG("enigmailMsgComposeOverlay.js: Enigmail.msg.keySelection(): call encryptTestMessage() for fromAddr=\""+fromAddr+"\" toAddr=\""+toAddr+"\" bccAddr=\""+bccAddr+"\" recipientsSelection="+recipientsSelection+"\n");
EnigmailCommon.DEBUG_LOG("enigmailMsgComposeOverlay.js: Enigmail.msg.encryptTestMessage(): call encryptMessage() for fromAddr=\""+fromAddr+"\" toAddr=\""+toAddr+"\" bccAddr=\""+bccAddr+"\" recipientsSelection="+recipientsSelection+"\n");
testCipher = enigmailSvc.encryptMessage(window, testUiFlags, testPlain,
fromAddr, toAddr, bccAddr,
testSendFlags,
......@@ -1487,7 +1502,7 @@ Enigmail.msg = {
// prepare dialog options:
inputObj.options = "multisel";
if (recipientsSelection==2) {
inputObj.options += ",rulesOption";
inputObj.options += ",rulesOption"; // enable button to create per-recipient rule
}
if (notSignedIfNotEnc) {
inputObj.options += ",notsigned";
......@@ -1523,7 +1538,9 @@ Enigmail.msg = {
if (! resultObj.encrypt) {
// encryption explicitely turned off
sendFlags &= ~ENCRYPT;
if (notSignedIfNotEnc) sendFlags &= ~SIGN;
if (notSignedIfNotEnc) {
sendFlags &= ~SIGN;
}
}
else {
if (bccAddrList.length > 0) {
......@@ -1548,7 +1565,8 @@ Enigmail.msg = {
EnigmailCommon.DEBUG_LOG("enigmailMsgComposeOverlay.js: Enigmail.msg.keySelection: No default encryption because test failed\n");
}
return {
doRulesProcessingAgain : false
doRulesProcessingAgain : false,
toAddr: toAddr
};
},
......
File mode changed from 100644 to 100755
......@@ -159,18 +159,24 @@ function enigmailBuildList(refresh) {
const TRUSTLEVEL_SORTED="oidreDn-qmfu"; // trust level sorted by increasing level of trust (see commonFuncs.jsm)
// sorting criterion for dialog entries
var sortUsers = function (a,b) {
var r = 0;
if ((a.activeState == 1 || b.activeState == 1) && (a.activeState != b.activeState)) {
// active keys in front of not active keys (note: we have values 0, 1, or 2)
if ((a.activeState != b.activeState) && (a.activeState == 1 || b.activeState == 1)) {
r = (a.activeState == 1 ? -1 : 1);
}
// keys matching invalid addresses in front
else if (a.uidMatchInvalid != b.uidMatchInvalid) {
r = (a.uidMatchInvalid == 1 ? -1 : 1);
}
// sort according to user IDs
else if (a.userId.toLowerCase()<b.userId.toLowerCase()) {
r = -1;
}
else {
r = 1;
}
return r;
};
......@@ -255,6 +261,7 @@ function enigmailBuildList(refresh) {
}
var aUserList = new Array();
var userObj = new Object();
userObj.uidMatchInvalid=false; // match any of the invalid keys
var i;
for (i=0; i<aGpgUserList.length; i++) {
var listRow=aGpgUserList[i].split(/:/);
......@@ -338,7 +345,7 @@ function enigmailBuildList(refresh) {
var invalidAddr = "";
try{
if (typeof(window.arguments[INPUT].invalidAddr)=="string" && !refresh) {
if (typeof(window.arguments[INPUT].invalidAddr)=="string") { // refresh did enable untrusted keys?: && !refresh) {
invalidAddr=" "+window.arguments[INPUT].invalidAddr+" ";
}
}
......@@ -392,9 +399,17 @@ function enigmailBuildList(refresh) {
escapedMailAddr=mailAddr.replace(escapeRegExp, "\\$1");
s1=new RegExp("[, ]?"+escapedMailAddr+"[, ]","i");
s2=new RegExp("[, ]"+escapedMailAddr+"[, ]?","i");
if ((mailAddr != EMPTY_UID) && (invalidAddr.indexOf(" "+mailAddr+" ")<0)) {
aValidUsers.push(mailAddr);
aUserList[i].activeState =(toAddr.search(s1)>=0 || toAddr.search(s2)>=0) ? 1 : 0;
if (mailAddr != EMPTY_UID) {
if (invalidAddr.indexOf(" "+mailAddr+" ")<0) {
aValidUsers.push(mailAddr);
aUserList[i].activeState =(toAddr.search(s1)>=0 || toAddr.search(s2)>=0) ? 1 : 0;
}
else {
// mail address found as invalid address: marks that to sort them to the beginning
aUserList[i].uidMatchInvalid = true;
aUserList[i].uidValid = false;
aUserList[i].activeState = 0;
}
}
else {
aUserList[i].uidValid = false;
......@@ -548,11 +563,15 @@ function enigUserSelCreateRow (userObj, activeState, userId, keyValue, dateField
var validity=EnigGetTrustLabel(uidValidityStatus.charAt(0));
if (!uidValid) {
userCol.setAttribute("properties", "enigKeyInactive");
uidValidityCol.setAttribute("properties", "enigKeyInactive");
expCol.setAttribute("properties", "enigKeyInactive");
keyCol.setAttribute("properties", "enigKeyInactive");
validity=EnigGetString("keyTrust.untrusted");
// if uid is not valid, set validity to "untrusted":
//userCol.setAttribute("properties", "enigKeyInactive");
//uidValidityCol.setAttribute("properties", "enigKeyInactive");
//expCol.setAttribute("properties", "enigKeyInactive");
//keyCol.setAttribute("properties", "enigKeyInactive");
if (validity=="-") {
validity="- ("+EnigGetString("keyTrust.untrusted").toUpperCase()+")";
}
keyCol.style.color = "red";
}
if (!userObj.subkeyOK && KEY_NOT_VALID.indexOf(uidValidityStatus.charAt(0))<0) {
validity=EnigGetString("keyValid.noSubkey");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment