-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] check for empty host when calling checkdnsrr() #22109
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
Changes from 1 commit
74629a4
b7f6db6
af3b0d9
fd9843a
61e2439
1683fee
00f8e7b
6a919dd
628c2d8
794f63d
756f9ce
b6f471a
7defce7
c9b4613
67e1dcc
bb05115
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Add empty on host in other methods where checkdnsrr is called and add unit tests to prevent future regressions
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,7 +118,7 @@ public function validate($value, Constraint $constraint) | |
*/ | ||
private function checkMX($host) | ||
{ | ||
if (null === $host || '' === $host) { | ||
if ('' === $host) { | ||
return false; | ||
} | ||
|
||
|
@@ -134,6 +134,10 @@ private function checkMX($host) | |
*/ | ||
private function checkHost($host) | ||
{ | ||
if ('' === $host) { | ||
return false; | ||
} | ||
|
||
return $this->checkMX($host) || (checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. preferred empty host condition in return statement |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,7 @@ public function validate($value, Constraint $constraint) | |
if ($constraint->checkDNS) { | ||
$host = parse_url($value, PHP_URL_HOST); | ||
|
||
if (!checkdnsrr($host, 'ANY')) { | ||
if ('' === $host || !checkdnsrr($host, 'ANY')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps switch to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a good idea. I'll do it thank you. |
||
$this->context->buildViolation($constraint->dnsMessage) | ||
->setParameter('{{ value }}', $this->formatValue($host)) | ||
->setCode(Url::INVALID_URL_ERROR) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preferred empty host condition in return statement