From a642640cf116ede50e1af46f7c0250c821242225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Obernd=C3=B6rfer?= Date: Thu, 18 Dec 2014 16:27:55 +0100 Subject: [PATCH] Keyring: use regex for email check. Fix exception if userid does not contain an email address. --- src/keyring/keyring.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/keyring/keyring.js b/src/keyring/keyring.js index cf78b1f61..2a3d2e994 100644 --- a/src/keyring/keyring.js +++ b/src/keyring/keyring.js @@ -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; } }