[Pkg-owncloud-commits] [owncloud] 61/90: Fix undefined offset 1 for wrong user mail address
David Prévot
taffit at moszumanska.debian.org
Fri Feb 6 21:10:54 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 491c714f543b03950c2f9b586f8646059c9b24ca
Author: Morris Jobke <hey at morrisjobke.de>
Date: Thu Jan 22 15:17:29 2015 +0100
Fix undefined offset 1 for wrong user mail address
* fixes Undefined offset: 1 at lib/private/mail.php#143
---
lib/private/mail.php | 3 +++
tests/lib/mail.php | 34 ++++++++++++++++++++++++----------
2 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/lib/private/mail.php b/lib/private/mail.php
index c23f3db..6043532 100644
--- a/lib/private/mail.php
+++ b/lib/private/mail.php
@@ -125,6 +125,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);
}
diff --git a/tests/lib/mail.php b/tests/lib/mail.php
index 3cc9868..6af977a 100644
--- a/tests/lib/mail.php
+++ b/tests/lib/mail.php
@@ -8,26 +8,23 @@
class Test_Mail extends PHPUnit_Framework_TestCase {
- protected function 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 at example.com', 'info at example.com'),
array('info at xn--cjr6vy5ejyai80u.com', 'info@國際化域名.com'),
@@ -36,4 +33,21 @@ class Test_Mail extends PHPUnit_Framework_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);
+ }
+
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list