MDL-58038 email: make sure all allowedemaildomain entries are respected

Fixes a bug with exploding the config var, in which trailing carriage
returns were causing string matches to fail.
This commit is contained in:
Jake Dallimore
2017-02-24 08:07:59 +08:00
parent d0209e611f
commit 3e0fb6862e
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -5812,7 +5812,7 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml = '',
$alloweddomains = null;
if (!empty($CFG->allowedemaildomains)) {
$alloweddomains = explode(PHP_EOL, $CFG->allowedemaildomains);
$alloweddomains = array_map('trim', explode("\n", $CFG->allowedemaildomains));
}
// Email will be sent using no reply address.
+1 -1
View File
@@ -2793,7 +2793,7 @@ class core_moodlelib_testcase extends advanced_testcase {
$user1 = $this->getDataGenerator()->create_user(array('maildisplay' => 1));
$user2 = $this->getDataGenerator()->create_user(array('maildisplay' => 1));
$user3 = $this->getDataGenerator()->create_user(array('maildisplay' => 0));
set_config('allowedemaildomains', 'example.com');
set_config('allowedemaildomains', "example.com\r\nmoodle.org");
$subject = 'subject';
$messagetext = 'message text';