MDL-21475 weblib: Simplify validate_email() to use existing function.

This commit is contained in:
Arjen Lentz 2019-02-18 11:30:32 +10:00
parent 124999563a
commit 4b71e99564
2 changed files with 140 additions and 16 deletions

View file

@ -1104,13 +1104,10 @@ function page_get_doc_link_path(moodle_page $page) {
* @return boolean
*/
function validate_email($address) {
global $CFG;
require_once($CFG->libdir.'/phpmailer/moodle_phpmailer.php');
return (bool)preg_match('#^[-!\#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+'.
'(\.[-!\#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+)*'.
'@'.
'[-!\#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.
'[-!\#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$#',
$address);
return moodle_phpmailer::validateAddress($address);
}
/**