MDL-74408 core: exclude empty patterns in divert email config.

This commit is contained in:
Paul Holden 2022-04-01 22:40:49 +01:00
parent 5500d143f4
commit d91df53d63
2 changed files with 17 additions and 1 deletions

View File

@ -5874,7 +5874,7 @@ function email_should_be_diverted($email) {
return true;
}
$patterns = array_map('trim', preg_split("/[\s,]+/", $CFG->divertallemailsexcept));
$patterns = array_map('trim', preg_split("/[\s,]+/", $CFG->divertallemailsexcept, -1, PREG_SPLIT_NO_EMPTY));
foreach ($patterns as $pattern) {
if (preg_match("/$pattern/", $email)) {
return false;

View File

@ -3408,6 +3408,22 @@ EOF;
),
true,
),
'alsodivertsblankline' => array(
'divertallemailsto' => 'somewhere@elsewhere.com',
'divertallemailsexcept' => "@dev.com\n",
[
'lionel@example.com',
],
true,
),
'divertsexceptionblankline' => array(
'divertallemailsto' => 'somewhere@elsewhere.com',
'divertallemailsexcept' => "@example.com\n",
[
'lionel@example.com',
],
false,
),
);
}