Keyring: use regex for email check. Fix exception if userid does not contain an email address.

This commit is contained in:
Thomas Oberndörfer 2014-12-18 16:27:55 +01:00
parent f79ce008b7
commit a642640cf1

View File

@ -123,12 +123,10 @@ KeyArray.prototype.getForAddress = function(email) {
* @return {Boolean} True if the email address is defined in the specified key
*/
function emailCheck(email, key) {
email = email.toLowerCase();
var emailRegex = new RegExp('<' + email.toLowerCase() + '>');
var keyEmails = key.getUserIds();
for (var i = 0; i < keyEmails.length; i++) {
//we need to get just the email from the userid key
keyEmail = keyEmails[i].split('<')[1].split('>')[0].trim().toLowerCase();
if (keyEmail == email) {
if (emailRegex.test(keyEmails[i].toLowerCase())) {
return true;
}
}