- Updates import email regex to use standard HTML5 regex
- Improves email detection/filtering logic
This commit is contained in:
@@ -304,28 +304,28 @@ define(
|
|||||||
advancedOptionDelimiter = '',
|
advancedOptionDelimiter = '',
|
||||||
advancedOptionNewline = '',
|
advancedOptionNewline = '',
|
||||||
advancedOptionComments = false,
|
advancedOptionComments = false,
|
||||||
// trim spaces, commas, periods,
|
// trim spaces, commas, periods,
|
||||||
// single/double quotes and convert to lowercase
|
// single/double quotes and convert to lowercase
|
||||||
detectAndCleanupEmail = function (email) {
|
detectAndCleanupEmail = function (email) {
|
||||||
email = email.toLowerCase();
|
var test;
|
||||||
var test,
|
// decode HTML entities
|
||||||
cleanEmail =
|
email = jQuery('<div />').html(email).text();
|
||||||
email
|
email = email
|
||||||
// left/right trim spaces, punctuation (e.g., " 'email@email.com'; ")
|
.toLowerCase()
|
||||||
// right trim non-printable characters (e.g., "email@email.com<EFBFBD>")
|
// left/right trim spaces, punctuation (e.g., " 'email@email.com'; ")
|
||||||
.replace(/^["';.,\s]+|[^\x20-\x7E]+$|["';.,_\s]+$/g, '')
|
// right trim non-printable characters (e.g., "email@email.com<6F>")
|
||||||
// remove spaces (e.g., "email @ email . com")
|
.replace(/^["';.,\s]+|[^\x20-\x7E]+$|["';.,_\s]+$/g, '')
|
||||||
// remove urlencoded characters
|
// remove spaces (e.g., "email @ email . com")
|
||||||
.replace(/\s+|%\d+|,+/g, '')
|
// remove urlencoded characters
|
||||||
.toLowerCase();
|
.replace(/\s+|%\d+|,+/g, '');
|
||||||
// detect e-mails that will otherwise be rejected by ^email_regex$
|
// detect e-mails that will be otherwise rejected by email regex
|
||||||
if (test = /<(.*?)>/.exec(email)) {
|
if (test = /<(.*?)>/.exec(email)) {
|
||||||
// is email inside angle brackets (e.g., 'some@email.com <some@email.com>')?
|
// is the email inside angle brackets (e.g., 'some@email.com <some@email.com>')?
|
||||||
return test[1].trim();
|
email = test[1].trim();
|
||||||
}
|
}
|
||||||
else if (test = /mailto:(?:\s+)?(.*)/.exec(email)) {
|
if (test = /mailto:(?:\s+)?(.*)/.exec(email)) {
|
||||||
// is email in 'mailto:email' format?
|
// is the email in 'mailto:email' format?
|
||||||
return test[1].trim();
|
email = test[1].trim();
|
||||||
}
|
}
|
||||||
return email;
|
return email;
|
||||||
};
|
};
|
||||||
|
@@ -25,7 +25,8 @@
|
|||||||
mailpoetColumnsSelect2 = <%= subscriberFieldsSelect2|raw %>,
|
mailpoetColumnsSelect2 = <%= subscriberFieldsSelect2|raw %>,
|
||||||
mailpoetColumns = <%= subscriberFields|raw %>,
|
mailpoetColumns = <%= subscriberFields|raw %>,
|
||||||
mailpoetSegments = <%= segments|raw %>,
|
mailpoetSegments = <%= segments|raw %>,
|
||||||
emailRegex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-_]{0,61}[a-zA-Z0-9])+.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
// HTML5 email regex: https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address
|
||||||
|
emailRegex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
||||||
</script>
|
</script>
|
||||||
<% endblock %>
|
<% endblock %>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user