Escape email before using as regular expression in emailCheck method.

This commit is contained in:
Thomas Oberndörfer 2015-03-05 13:32:44 +01:00
parent 37091175b1
commit be6ae2c464

View File

@ -123,7 +123,9 @@ KeyArray.prototype.getForAddress = function(email) {
* @return {Boolean} True if the email address is defined in the specified key * @return {Boolean} True if the email address is defined in the specified key
*/ */
function emailCheck(email, key) { function emailCheck(email, key) {
var emailRegex = new RegExp('<' + email.toLowerCase() + '>'); // escape email before using in regular expression
email = email.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
var emailRegex = new RegExp('<' + email + '>');
var keyEmails = key.getUserIds(); var keyEmails = key.getUserIds();
for (var i = 0; i < keyEmails.length; i++) { for (var i = 0; i < keyEmails.length; i++) {
if (emailRegex.test(keyEmails[i].toLowerCase())) { if (emailRegex.test(keyEmails[i].toLowerCase())) {