From 652b2e496a64e2c01fc66b4b2959e9677dfbe33a Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 8 Nov 2022 20:57:57 +0000 Subject: [PATCH] MDL-76235 core: compare email diversion exceptions case-insensitively. Co-authored-by: Jan Kristoffer Roth --- lib/moodlelib.php | 2 +- lib/tests/moodlelib_test.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index d22c8dad008..2f639c887d8 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -5920,7 +5920,7 @@ function email_should_be_diverted($email) { $patterns = array_map('trim', preg_split("/[\s,]+/", $CFG->divertallemailsexcept, -1, PREG_SPLIT_NO_EMPTY)); foreach ($patterns as $pattern) { - if (preg_match("/$pattern/", $email)) { + if (preg_match("/{$pattern}/i", $email)) { return false; } } diff --git a/lib/tests/moodlelib_test.php b/lib/tests/moodlelib_test.php index f10155671b3..7aa43a8d5f2 100644 --- a/lib/tests/moodlelib_test.php +++ b/lib/tests/moodlelib_test.php @@ -3426,6 +3426,7 @@ EOF; 'foo@example.com', 'test@real.com', 'fred.jones@example.com', + 'Fred.Jones@Example.com', ), true, ), @@ -3435,6 +3436,7 @@ EOF; array( 'dev1@dev.com', 'fred@example.com', + 'Fred@Example.com', 'fred+verp@example.com', ), false,