summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_mail.class2
-rwxr-xr-xtest/it_mail.t4
2 files changed, 3 insertions, 3 deletions
diff --git a/it_mail.class b/it_mail.class
index eb2cbb9..4119994 100644
--- a/it_mail.class
+++ b/it_mail.class
@@ -419,7 +419,7 @@ static function address_error($addresslist)
}
foreach ($addresses as $address)
- if (($email = it::match('<([^>]*)', $address) ?? $address))
+ if (($email = it::match('<([^>]*)>', $address) ?? trim($address)))
if (filter_var($email, FILTER_VALIDATE_EMAIL) === false && !it::match('^\s*[a-z][-a-z0-9]*\s*$', $email))
return "invalid format on $email";
}
diff --git a/test/it_mail.t b/test/it_mail.t
index 8b9a316..7e892c2 100755
--- a/test/it_mail.t
+++ b/test/it_mail.t
@@ -95,10 +95,10 @@ is(
);
is(
- it_mail::address_error('neuman@example.com, <neuman@example.com>, "Neuman, Alfred E." <neuman@example.com>, aneuman'),
+ it_mail::address_error('neuman@example.com, <neuman@example.com>, "Neuman, Alfred E." <neuman@example.com>, aneuman, "<neuman@example>" <neuman@example.com>', " neumann@example.com"),
null,
"Accept valid e-mail addresses"
);
-foreach (['neuman@example', '"neuman@example.com" <neuman@example>'] as $email)
+foreach (['neuman@example', '"neuman@example.com" <neuman@example>', '<neuma@example.com'] as $email)
isnt(it_mail::address_error($email), null, "Reject invalid e-mail address $email");