Merge pull request #13598 from owncloud/fix-undefined-offset
Fix undefined offset 1 for wrong user mail address
This commit is contained in:
commit
8f06bf7bc6
2 changed files with 27 additions and 12 deletions
|
@ -126,6 +126,9 @@ class OC_Mail {
|
|||
* @return bool
|
||||
*/
|
||||
public static function validateAddress($emailAddress) {
|
||||
if (strpos($emailAddress, '@') === false) {
|
||||
return false;
|
||||
}
|
||||
$emailAddress = self::buildAsciiEmail($emailAddress);
|
||||
return PHPMailer::ValidateAddress($emailAddress);
|
||||
}
|
||||
|
|
|
@ -8,28 +8,23 @@
|
|||
|
||||
class Test_Mail extends \Test\TestCase {
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (!function_exists('idn_to_ascii')) {
|
||||
$this->markTestSkipped(
|
||||
'The intl extension is not available.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider buildAsciiEmailProvider
|
||||
* @param $expected
|
||||
* @param $address
|
||||
*/
|
||||
public function testBuildAsciiEmail($expected, $address) {
|
||||
if (!function_exists('idn_to_ascii')) {
|
||||
$this->markTestSkipped(
|
||||
'The intl extension is not available.'
|
||||
);
|
||||
}
|
||||
|
||||
$actual = \OC_Mail::buildAsciiEmail($address);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
function buildAsciiEmailProvider() {
|
||||
public function buildAsciiEmailProvider() {
|
||||
return array(
|
||||
array('info@example.com', 'info@example.com'),
|
||||
array('info@xn--cjr6vy5ejyai80u.com', 'info@國際化域名.com'),
|
||||
|
@ -38,4 +33,21 @@ class Test_Mail extends \Test\TestCase {
|
|||
);
|
||||
}
|
||||
|
||||
public function validateMailProvider() {
|
||||
return array(
|
||||
array('infoatexample.com', false),
|
||||
array('info', false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider validateMailProvider
|
||||
* @param $address
|
||||
* @param $expected
|
||||
*/
|
||||
public function testValidateEmail($address, $expected) {
|
||||
$actual = \OC_Mail::validateAddress($address);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue