- Updates import email regex to use standard HTML5 regex
- Improves email detection/filtering logic
This commit is contained in:
@@ -307,25 +307,25 @@ define(
|
||||
// trim spaces, commas, periods,
|
||||
// single/double quotes and convert to lowercase
|
||||
detectAndCleanupEmail = function (email) {
|
||||
email = email.toLowerCase();
|
||||
var test,
|
||||
cleanEmail =
|
||||
email
|
||||
var test;
|
||||
// decode HTML entities
|
||||
email = jQuery('<div />').html(email).text();
|
||||
email = email
|
||||
.toLowerCase()
|
||||
// left/right trim spaces, punctuation (e.g., " 'email@email.com'; ")
|
||||
// right trim non-printable characters (e.g., "email@email.com<6F>")
|
||||
.replace(/^["';.,\s]+|[^\x20-\x7E]+$|["';.,_\s]+$/g, '')
|
||||
// remove spaces (e.g., "email @ email . com")
|
||||
// remove urlencoded characters
|
||||
.replace(/\s+|%\d+|,+/g, '')
|
||||
.toLowerCase();
|
||||
// detect e-mails that will otherwise be rejected by ^email_regex$
|
||||
.replace(/\s+|%\d+|,+/g, '');
|
||||
// detect e-mails that will be otherwise rejected by email regex
|
||||
if (test = /<(.*?)>/.exec(email)) {
|
||||
// is email inside angle brackets (e.g., 'some@email.com <some@email.com>')?
|
||||
return test[1].trim();
|
||||
// is the email inside angle brackets (e.g., 'some@email.com <some@email.com>')?
|
||||
email = test[1].trim();
|
||||
}
|
||||
else if (test = /mailto:(?:\s+)?(.*)/.exec(email)) {
|
||||
// is email in 'mailto:email' format?
|
||||
return test[1].trim();
|
||||
if (test = /mailto:(?:\s+)?(.*)/.exec(email)) {
|
||||
// is the email in 'mailto:email' format?
|
||||
email = test[1].trim();
|
||||
}
|
||||
return email;
|
||||
};
|
||||
|
@@ -25,7 +25,8 @@
|
||||
mailpoetColumnsSelect2 = <%= subscriberFieldsSelect2|raw %>,
|
||||
mailpoetColumns = <%= subscriberFields|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>
|
||||
<% endblock %>
|
||||
|
||||
|
Reference in New Issue
Block a user