diff --git a/mozilla/mail/base/content/mailCommands.js b/mozilla/mail/base/content/mailCommands.js index b6c788a6b92..fc5d80ec862 100644 --- a/mozilla/mail/base/content/mailCommands.js +++ b/mozilla/mail/base/content/mailCommands.js @@ -70,6 +70,8 @@ function getBestIdentity(identities, optionalHint) { var identity = null; + try + { // if we have more than one identity and a hint to help us pick one if (identities.Count() > 1 && optionalHint) { // normalize case on the optional hint to improve our chances of finding a match @@ -106,6 +108,8 @@ function getBestIdentity(identities, optionalHint) } } } + } + catch (ex) {dump (ex + "\n");} // still no matches? Give up and pick the first one like we used to. if (!identity) diff --git a/mozilla/mailnews/base/resources/content/mailCommands.js b/mozilla/mailnews/base/resources/content/mailCommands.js index 87794a302ae..7d85b2fe065 100644 --- a/mozilla/mailnews/base/resources/content/mailCommands.js +++ b/mozilla/mailnews/base/resources/content/mailCommands.js @@ -89,40 +89,44 @@ function getBestIdentity(identities, optionalHint) { var identity = null; - // if we have more than one identity and a hint to help us pick one - if (identities.Count() > 1 && optionalHint) { - // iterate over all of the identities - var tempID; - for (id = 0; id < identities.Count(); id++) { - tempID = identities.GetElementAt(id).QueryInterface(Components.interfaces.nsIMsgIdentity); - if (optionalHint.search(tempID.email) >= 0) { - identity = tempID; - break; - } - } - - // if we could not find an exact email address match within the hint fields then maybe the message - // was to a mailing list. In this scenario, we won't have a match based on email address. - // Before we just give up, try and search for just a shared domain between the the hint and - // the email addresses for our identities. Hey, it is better than nothing and in the case - // of multiple matches here, we'll end up picking the first one anyway which is what we would have done - // if we didn't do this second search. This helps the case for corporate users where mailing lists will have the same domain - // as one of your multiple identities. - - if (!identity) { + try + { + // if we have more than one identity and a hint to help us pick one + if (identities.Count() > 1 && optionalHint) { + // iterate over all of the identities + var tempID; for (id = 0; id < identities.Count(); id++) { tempID = identities.GetElementAt(id).QueryInterface(Components.interfaces.nsIMsgIdentity); - - // extract out the partial domain - var start = tempID.email.lastIndexOf("@"); // be sure to include the @ sign in our search to reduce the risk of false positives - - if (optionalHint.search(tempID.email.slice(start, tempID.email.length)) >= 0) { + if (optionalHint.search(tempID.email) >= 0) { identity = tempID; break; } } + + // if we could not find an exact email address match within the hint fields then maybe the message + // was to a mailing list. In this scenario, we won't have a match based on email address. + // Before we just give up, try and search for just a shared domain between the the hint and + // the email addresses for our identities. Hey, it is better than nothing and in the case + // of multiple matches here, we'll end up picking the first one anyway which is what we would have done + // if we didn't do this second search. This helps the case for corporate users where mailing lists will have the same domain + // as one of your multiple identities. + + if (!identity) { + for (id = 0; id < identities.Count(); id++) { + tempID = identities.GetElementAt(id).QueryInterface(Components.interfaces.nsIMsgIdentity); + + // extract out the partial domain + var start = tempID.email.lastIndexOf("@"); // be sure to include the @ sign in our search to reduce the risk of false positives + + if (optionalHint.search(tempID.email.slice(start, tempID.email.length)) >= 0) { + identity = tempID; + break; + } + } + } } } + catch (ex) {dump (ex + "\n");} // still no matches? Give up and pick the first one like we used to. if (!identity)