Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Validator] add domain test for windows check dns #27559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add deprecated on checkMX and checkHost on Email Validator
  • Loading branch information
Vangest Olivier committed Aug 4, 2018
commit b2701406c4543bd2e581a209e1f04c5b08c7e37a
25 changes: 7 additions & 18 deletions src/Symfony/Component/Validator/Constraints/EmailValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
*/
class EmailValidator extends ConstraintValidator
{
const DOMAIN_PATTERN = '/^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/';
private $isStrict;

/**
* @param bool $strict
* @var bool
*/
private $isStrict;

public function __construct($strict = false)
{
$this->isStrict = $strict;
Expand Down Expand Up @@ -130,18 +129,6 @@ public function validate($value, Constraint $constraint)
}
}

/**
* Check if host domain is valid.
*
* @param string $host Host
*
* @return bool
*/
private function checkHostDomain($host)
{
return preg_match(static::DOMAIN_PATTERN, $host);
}

/**
* Check DNS Records for MX type.
*
Expand All @@ -151,7 +138,8 @@ private function checkHostDomain($host)
*/
private function checkMX($host)
{
return $this->checkHostDomain($host) && checkdnsrr($host, 'MX');
@trigger_error(__METHOD__.'() is deprecated since Symfony 2.8 and will be removed in 5.0.', E_USER_DEPRECATED);
return '' !== $host && checkdnsrr($host, 'MX');
}

/**
Expand All @@ -163,6 +151,7 @@ private function checkMX($host)
*/
private function checkHost($host)
{
return $this->checkHostDomain($host) && ($this->checkMX($host) || (checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA')));
@trigger_error(__METHOD__.'() is deprecated since Symfony 2.8 and will be removed in 5.0.', E_USER_DEPRECATED);
return '' !== $host && ($this->checkMX($host) || (checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA')));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public function getInvalidEmails()
array('example'),
array('example@'),
array('example@localhost'),
array('example@gmailcom'),
array('[email protected] bar'),
);
}
Expand Down