Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Validator] Deprecated "checkDNS" option in Url constraint #25516

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 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions 1 UPGRADE-4.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Validator

* The `Email::__construct()` 'strict' property is deprecated and will be removed in 5.0. Use 'mode'=>"strict" instead.
* Calling `EmailValidator::__construct()` method with a boolean parameter is deprecated and will be removed in 5.0, use `EmailValidator("strict")` instead.
* Deprecated the `checkDNS` and `dnsMessage` options of the `Url` constraint. They will be removed in 5.0.

Workflow
--------
Expand Down
2 changes: 1 addition & 1 deletion 2 UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Validator

* The `Email::__construct()` 'strict' property has been removed. Use 'mode'=>"strict" instead.
* Calling `EmailValidator::__construct()` method with a boolean parameter has been removed, use `EmailValidator("strict")` instead.

* Removed the `checkDNS` and `dnsMessage` options from the `Url` constraint.

Workflow
--------
Expand Down
5 changes: 5 additions & 0 deletions 5 src/Symfony/Component/Validator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

4.1.0
-----

* Deprecated the `checkDNS` and `dnsMessage` options of the `Url` constraint. They will be removed in 5.0.

4.0.0
-----

Expand Down
59 changes: 59 additions & 0 deletions 59 src/Symfony/Component/Validator/Constraints/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,57 @@
*/
class Url extends Constraint
{
/**
* @deprecated since Symfony 4.1, to be removed in 5.0
*/
const CHECK_DNS_TYPE_ANY = 'ANY';
/**
* @deprecated since Symfony 4.1, to be removed in 5.0
*/
const CHECK_DNS_TYPE_NONE = false;
/**
* @deprecated since Symfony 4.1, to be removed in 5.0
*/
const CHECK_DNS_TYPE_A = 'A';
/**
* @deprecated since Symfony 4.1, to be removed in 5.0
*/
const CHECK_DNS_TYPE_A6 = 'A6';
/**
* @deprecated since Symfony 4.1, to be removed in 5.0
*/
const CHECK_DNS_TYPE_AAAA = 'AAAA';
/**
* @deprecated since Symfony 4.1, to be removed in 5.0
*/
const CHECK_DNS_TYPE_CNAME = 'CNAME';
/**
* @deprecated since Symfony 4.1, to be removed in 5.0
*/
const CHECK_DNS_TYPE_MX = 'MX';
/**
* @deprecated since Symfony 4.1, to be removed in 5.0
*/
const CHECK_DNS_TYPE_NAPTR = 'NAPTR';
/**
* @deprecated since Symfony 4.1, to be removed in 5.0
*/
const CHECK_DNS_TYPE_NS = 'NS';
/**
* @deprecated since Symfony 4.1, to be removed in 5.0
*/
const CHECK_DNS_TYPE_PTR = 'PTR';
/**
* @deprecated since Symfony 4.1, to be removed in 5.0
*/
const CHECK_DNS_TYPE_SOA = 'SOA';
/**
* @deprecated since Symfony 4.1, to be removed in 5.0
*/
const CHECK_DNS_TYPE_SRV = 'SRV';
/**
* @deprecated since Symfony 4.1, to be removed in 5.0
*/
const CHECK_DNS_TYPE_TXT = 'TXT';

const INVALID_URL_ERROR = '57c2f299-1154-4870-89bb-ef3b1f5ad229';
Expand All @@ -42,7 +81,27 @@ class Url extends Constraint
);

public $message = 'This value is not a valid URL.';
/**
* @deprecated since Symfony 4.1, to be removed in 5.0
*/
public $dnsMessage = 'The host could not be resolved.';
public $protocols = array('http', 'https');
/**
* @deprecated since Symfony 4.1, to be removed in 5.0
*/
public $checkDNS = self::CHECK_DNS_TYPE_NONE;

public function __construct($options = null)
{
if (is_array($options)) {
if (array_key_exists('checkDNS', $options)) {
@trigger_error(sprintf('The "checkDNS" option in "%s" is deprecated since Symfony 4.1 and will be removed in 5.0. Its false-positive rate is too high to be relied upon.', self::class), E_USER_DEPRECATED);
}
if (array_key_exists('dnsMessage', $options)) {
@trigger_error(sprintf('The "dnsMessage" option in "%s" is deprecated since Symfony 4.1 and will be removed in 5.0.', self::class), E_USER_DEPRECATED);
}
}

parent::__construct($options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ public function getValidCustomUrls()
/**
* @dataProvider getCheckDns
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
* @group legacy
* @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1 and will be removed in 5.0. Its false-positive rate is too high to be relied upon.
*/
public function testCheckDns($violation)
{
Expand Down Expand Up @@ -230,6 +232,8 @@ public function getCheckDns()
/**
* @dataProvider getCheckDnsTypes
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
* @group legacy
* @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1 and will be removed in 5.0. Its false-positive rate is too high to be relied upon.
*/
public function testCheckDnsByType($type)
{
Expand Down Expand Up @@ -266,6 +270,9 @@ public function getCheckDnsTypes()
/**
* @expectedException \Symfony\Component\Validator\Exception\InvalidOptionsException
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
* @group legacy
* @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1 and will be removed in 5.0. Its false-positive rate is too high to be relied upon.
* @expectedDeprecation The "dnsMessage" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1 and will be removed in 5.0.
*/
public function testCheckDnsWithInvalidType()
{
Expand All @@ -278,6 +285,19 @@ public function testCheckDnsWithInvalidType()

$this->validator->validate('http://example.com', $constraint);
}

/**
* @group legacy
* @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1 and will be removed in 5.0. Its false-positive rate is too high to be relied upon.
*/
public function testCheckDnsOptionIsDeprecated()
{
$constraint = new Url(array(
'checkDNS' => Url::CHECK_DNS_TYPE_NONE,
));

$this->validator->validate('http://example.com', $constraint);
}
}

class EmailProvider
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.