Commit 95398e81 authored by Lisa Seeto's avatar Lisa Seeto
Browse files

Bug 1813101: use correct email syntax for noreply address



If the default noreply email address is invalid set it to a valid format
and make sure warnings still display to user

behatnotneeded

Change-Id: I390d2d62ac39aef49144a69d4edb1f0a3918fd8e
Signed-off-by: default avatarLisa Seeto <lisaseeto@catalyst.net.nz>
parent 8400b75d
...@@ -278,7 +278,11 @@ if ($CFG->sslproxy === false && isset($_SERVER['REMOTE_ADDR']) && (!isset($_SERV ...@@ -278,7 +278,11 @@ if ($CFG->sslproxy === false && isset($_SERVER['REMOTE_ADDR']) && (!isset($_SERV
} }
if (!isset($CFG->noreplyaddress) && isset($CFG->wwwroot)) { if (!isset($CFG->noreplyaddress) && isset($CFG->wwwroot)) {
$noreplyaddress = 'noreply@' . parse_url($CFG->wwwroot, PHP_URL_HOST); $noreplyaddress = 'noreply@' . parse_url($CFG->wwwroot, PHP_URL_HOST);
try { try {
if (!sanitize_email($noreplyaddress)) {
$noreplyaddress = 'noreply@example.org';
}
set_config('noreplyaddress', $noreplyaddress); set_config('noreplyaddress', $noreplyaddress);
} }
catch (Exception $e) { catch (Exception $e) {
......
...@@ -1571,7 +1571,7 @@ function site_warnings() { ...@@ -1571,7 +1571,7 @@ function site_warnings() {
} }
// Check noreply address is valid. // Check noreply address is valid.
if (!sanitize_email(get_config('noreplyaddress'))) { if (!sanitize_email(get_config('noreplyaddress')) || get_config('noreplyaddress') == 'noreply@example.org') {
$warnings[] = get_string('noreplyaddressmissingorinvalid', 'error', get_config('wwwroot') . 'admin/site/options.php?fs=emailsettings'); $warnings[] = get_string('noreplyaddressmissingorinvalid', 'error', get_config('wwwroot') . 'admin/site/options.php?fs=emailsettings');
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment