mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-76559 core: validate_email should not accept empty values
This commit is contained in:
parent
1d863c338a
commit
f375cac31a
2 changed files with 20 additions and 1 deletions
|
@ -595,6 +595,20 @@ EXPECTED;
|
|||
'result' => false
|
||||
],
|
||||
|
||||
// Empty e-mail addresess are not valid.
|
||||
[
|
||||
'email' => '',
|
||||
'result' => false,
|
||||
],
|
||||
[
|
||||
'email' => null,
|
||||
'result' => false,
|
||||
],
|
||||
[
|
||||
'email' => false,
|
||||
'result' => false,
|
||||
],
|
||||
|
||||
// Extra email addresses from Wikipedia page on Email Addresses.
|
||||
// Valid.
|
||||
[
|
||||
|
|
|
@ -1108,7 +1108,12 @@ function page_get_doc_link_path(moodle_page $page) {
|
|||
*/
|
||||
function validate_email($address) {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir.'/phpmailer/moodle_phpmailer.php');
|
||||
|
||||
if ($address === null || $address === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
require_once("{$CFG->libdir}/phpmailer/moodle_phpmailer.php");
|
||||
|
||||
return moodle_phpmailer::validateAddress($address) && !preg_match('/[<>]/', $address);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue