Skip to content

Commit

Permalink
MDL-66762 user: stricter email validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden authored and abgreeve committed Nov 7, 2019
1 parent d6c704b commit eb9f830
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions lib/tests/weblib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,18 @@ public function data_validate_email() {
'email' => "[email protected]>\r\nRCPT TO:<[email protected]",
'result' => false
],
[
'email' => 'greater>[email protected]',
'result' => false
],
[
'email' => 'less<[email protected]',
'result' => false
],
[
'email' => '"this<is>validbutwerejectit"@example.com',
'result' => false
],

// Extra email addresses from Wikipedia page on Email Addresses.
// Valid.
Expand Down
2 changes: 1 addition & 1 deletion lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ function validate_email($address) {
global $CFG;
require_once($CFG->libdir.'/phpmailer/moodle_phpmailer.php');

return moodle_phpmailer::validateAddress($address);
return moodle_phpmailer::validateAddress($address) && !preg_match('/[<>]/', $address);
}

/**
Expand Down

0 comments on commit eb9f830

Please sign in to comment.