mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Merge branch 'MDL-57531-master-phpmailer' of git://github.com/mudrd8mz/moodle
This commit is contained in:
commit
b6f5e57e45
6 changed files with 63 additions and 6 deletions
|
@ -3425,4 +3425,27 @@ class core_moodlelib_testcase extends advanced_testcase {
|
|||
'samecourse' => false, 'result' => false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that generate_email_processing_address() returns valid email address.
|
||||
*/
|
||||
public function test_generate_email_processing_address() {
|
||||
global $CFG;
|
||||
$this->resetAfterTest();
|
||||
|
||||
$data = (object)[
|
||||
'id' => 42,
|
||||
'email' => 'my.email+from_moodle@example.com',
|
||||
];
|
||||
|
||||
$modargs = 'B'.base64_encode(pack('V', $data->id)).substr(md5($data->email), 0, 16);
|
||||
|
||||
$CFG->maildomain = 'example.com';
|
||||
$CFG->mailprefix = 'mdl+';
|
||||
$this->assertTrue(validate_email(generate_email_processing_address(0, $modargs)));
|
||||
|
||||
$CFG->maildomain = 'mail.example.com';
|
||||
$CFG->mailprefix = 'mdl-';
|
||||
$this->assertTrue(validate_email(generate_email_processing_address(23, $modargs)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -665,4 +665,19 @@ EXPECTED;
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for validate_email() function.
|
||||
*/
|
||||
public function test_validate_email() {
|
||||
|
||||
$this->assertTrue(validate_email('moodle@example.com'));
|
||||
$this->assertTrue(validate_email('moodle@localhost.local'));
|
||||
$this->assertTrue(validate_email('verp_email+is=mighty@moodle.org'));
|
||||
$this->assertTrue(validate_email("but_potentially'dangerous'too@example.org"));
|
||||
$this->assertTrue(validate_email('posts+AAAAAAAAAAIAAAAAAAAGQQAAAAABFSXz1eM/P/lR2bYyljM+@posts.moodle.org'));
|
||||
|
||||
$this->assertFalse(validate_email('moodle@localhost'));
|
||||
$this->assertFalse(validate_email('"attacker\\" -oQ/tmp/ -X/var/www/vhost/moodle/backdoor.php some"@email.com'));
|
||||
$this->assertFalse(validate_email("moodle@example.com>\r\nRCPT TO:<victim@example.com"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue