consolidate email validation checks
This commit is contained in:
parent
4f577cbdeb
commit
1de1b58a08
@ -49,7 +49,7 @@ class Invite extends \Zotlabs\Web\Controller {
|
|||||||
if(! $recip)
|
if(! $recip)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(! valid_email($recip)) {
|
if(! validate_email($recip)) {
|
||||||
notice( sprintf( t('%s : Not a valid email address.'), $recip) . EOL);
|
notice( sprintf( t('%s : Not a valid email address.'), $recip) . EOL);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ class Account {
|
|||||||
|
|
||||||
$account = \App::get_account();
|
$account = \App::get_account();
|
||||||
if($email != $account['account_email']) {
|
if($email != $account['account_email']) {
|
||||||
if(! valid_email($email))
|
if(! validate_email($email))
|
||||||
$errs[] = t('Not valid email.');
|
$errs[] = t('Not valid email.');
|
||||||
$adm = trim(get_config('system','admin_email'));
|
$adm = trim(get_config('system','admin_email'));
|
||||||
if(($adm) && (strcasecmp($email,$adm) == 0)) {
|
if(($adm) && (strcasecmp($email,$adm) == 0)) {
|
||||||
|
@ -31,7 +31,7 @@ function check_account_email($email) {
|
|||||||
if(! strlen($email))
|
if(! strlen($email))
|
||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
if((! valid_email($email)) || (! validate_email($email)))
|
if(! validate_email($email))
|
||||||
$result['message'] .= t('Not a valid email address') . EOL;
|
$result['message'] .= t('Not a valid email address') . EOL;
|
||||||
elseif(! allowed_email($email))
|
elseif(! allowed_email($email))
|
||||||
$result['message'] = t('Your email domain is not among those allowed on this site');
|
$result['message'] = t('Your email domain is not among those allowed on this site');
|
||||||
|
@ -1042,19 +1042,6 @@ function searchbox($s,$id='search-box',$url='/search',$save = false) {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
function valid_email_regex($x){
|
|
||||||
if(preg_match('/^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9\-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function valid_email($x){
|
|
||||||
if(get_config('system','disable_email_validation'))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return valid_email_regex($x);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Replace naked text hyperlink with HTML formatted hyperlink.
|
* @brief Replace naked text hyperlink with HTML formatted hyperlink.
|
||||||
*
|
*
|
||||||
|
@ -11,18 +11,6 @@ use Zotlabs\Tests\Unit\UnitTestCase;
|
|||||||
*/
|
*/
|
||||||
class TextTest extends UnitTestCase {
|
class TextTest extends UnitTestCase {
|
||||||
|
|
||||||
public function testGoodEmail() {
|
|
||||||
$this->assertTrue(valid_email_regex('ken@spaz.org'));
|
|
||||||
$this->assertTrue(valid_email_regex('ken@restivo.org'));
|
|
||||||
$this->assertTrue(valid_email_regex('nobody@hubzilla.org'));
|
|
||||||
$this->assertTrue(valid_email_regex('foo+nobody@hubzilla.org'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testBadEmail() {
|
|
||||||
$this->assertFalse(valid_email_regex('nobody!uses!these!any.more'));
|
|
||||||
$this->assertFalse(valid_email_regex('foo@bar@hubzilla.org'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testPurifyHTML() {
|
public function testPurifyHTML() {
|
||||||
// linebreaks
|
// linebreaks
|
||||||
$htmlbr = 'first line<br />
|
$htmlbr = 'first line<br />
|
||||||
|
Reference in New Issue
Block a user