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

Commit 885703f

Browse filesBrowse files
committed
[Validator] Remove checkDNS option in Url
1 parent 9cc2a4e commit 885703f
Copy full SHA for 885703f

File tree

3 files changed

+0
-219
lines changed
Filter options

3 files changed

+0
-219
lines changed

‎src/Symfony/Component/Validator/Constraints/Url.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Url.php
-84Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -22,103 +22,19 @@
2222
*/
2323
class Url extends Constraint
2424
{
25-
/**
26-
* @deprecated since Symfony 4.1
27-
*/
28-
const CHECK_DNS_TYPE_ANY = 'ANY';
29-
30-
/**
31-
* @deprecated since Symfony 4.1
32-
*/
33-
const CHECK_DNS_TYPE_NONE = false;
34-
35-
/**
36-
* @deprecated since Symfony 4.1
37-
*/
38-
const CHECK_DNS_TYPE_A = 'A';
39-
40-
/**
41-
* @deprecated since Symfony 4.1
42-
*/
43-
const CHECK_DNS_TYPE_A6 = 'A6';
44-
45-
/**
46-
* @deprecated since Symfony 4.1
47-
*/
48-
const CHECK_DNS_TYPE_AAAA = 'AAAA';
49-
50-
/**
51-
* @deprecated since Symfony 4.1
52-
*/
53-
const CHECK_DNS_TYPE_CNAME = 'CNAME';
54-
55-
/**
56-
* @deprecated since Symfony 4.1
57-
*/
58-
const CHECK_DNS_TYPE_MX = 'MX';
59-
60-
/**
61-
* @deprecated since Symfony 4.1
62-
*/
63-
const CHECK_DNS_TYPE_NAPTR = 'NAPTR';
64-
65-
/**
66-
* @deprecated since Symfony 4.1
67-
*/
68-
const CHECK_DNS_TYPE_NS = 'NS';
69-
70-
/**
71-
* @deprecated since Symfony 4.1
72-
*/
73-
const CHECK_DNS_TYPE_PTR = 'PTR';
74-
75-
/**
76-
* @deprecated since Symfony 4.1
77-
*/
78-
const CHECK_DNS_TYPE_SOA = 'SOA';
79-
80-
/**
81-
* @deprecated since Symfony 4.1
82-
*/
83-
const CHECK_DNS_TYPE_SRV = 'SRV';
84-
85-
/**
86-
* @deprecated since Symfony 4.1
87-
*/
88-
const CHECK_DNS_TYPE_TXT = 'TXT';
89-
9025
const INVALID_URL_ERROR = '57c2f299-1154-4870-89bb-ef3b1f5ad229';
9126

9227
protected static $errorNames = [
9328
self::INVALID_URL_ERROR => 'INVALID_URL_ERROR',
9429
];
9530

9631
public $message = 'This value is not a valid URL.';
97-
98-
/**
99-
* @deprecated since Symfony 4.1
100-
*/
101-
public $dnsMessage = 'The host could not be resolved.';
10232
public $protocols = ['http', 'https'];
103-
104-
/**
105-
* @deprecated since Symfony 4.1
106-
*/
107-
public $checkDNS = self::CHECK_DNS_TYPE_NONE;
10833
public $relativeProtocol = false;
10934
public $normalizer;
11035

11136
public function __construct($options = null)
11237
{
113-
if (\is_array($options)) {
114-
if (\array_key_exists('checkDNS', $options)) {
115-
@trigger_error(sprintf('The "checkDNS" option in "%s" is deprecated since Symfony 4.1. Its false-positive rate is too high to be relied upon.', self::class), E_USER_DEPRECATED);
116-
}
117-
if (\array_key_exists('dnsMessage', $options)) {
118-
@trigger_error(sprintf('The "dnsMessage" option in "%s" is deprecated since Symfony 4.1.', self::class), E_USER_DEPRECATED);
119-
}
120-
}
121-
12238
parent::__construct($options);
12339

12440
if (null !== $this->normalizer && !\is_callable($this->normalizer)) {

‎src/Symfony/Component/Validator/Constraints/UrlValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/UrlValidator.php
-29Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\ConstraintValidator;
16-
use Symfony\Component\Validator\Exception\InvalidOptionsException;
1716
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1817
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1918

@@ -77,33 +76,5 @@ public function validate($value, Constraint $constraint)
7776

7877
return;
7978
}
80-
81-
if ($constraint->checkDNS) {
82-
if (!\in_array($constraint->checkDNS, [
83-
Url::CHECK_DNS_TYPE_ANY,
84-
Url::CHECK_DNS_TYPE_A,
85-
Url::CHECK_DNS_TYPE_A6,
86-
Url::CHECK_DNS_TYPE_AAAA,
87-
Url::CHECK_DNS_TYPE_CNAME,
88-
Url::CHECK_DNS_TYPE_MX,
89-
Url::CHECK_DNS_TYPE_NAPTR,
90-
Url::CHECK_DNS_TYPE_NS,
91-
Url::CHECK_DNS_TYPE_PTR,
92-
Url::CHECK_DNS_TYPE_SOA,
93-
Url::CHECK_DNS_TYPE_SRV,
94-
Url::CHECK_DNS_TYPE_TXT,
95-
], true)) {
96-
throw new InvalidOptionsException(sprintf('Invalid value for option "checkDNS" in constraint %s', \get_class($constraint)), ['checkDNS']);
97-
}
98-
99-
$host = parse_url($value, PHP_URL_HOST);
100-
101-
if (!\is_string($host) || !checkdnsrr($host, $constraint->checkDNS)) {
102-
$this->context->buildViolation($constraint->dnsMessage)
103-
->setParameter('{{ value }}', $this->formatValue($host))
104-
->setCode(Url::INVALID_URL_ERROR)
105-
->addViolation();
106-
}
107-
}
10879
}
10980
}

‎src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php
-106Lines changed: 0 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@
1111

1212
namespace Symfony\Component\Validator\Tests\Constraints;
1313

14-
use Symfony\Bridge\PhpUnit\DnsMock;
1514
use Symfony\Component\Validator\Constraints\Url;
1615
use Symfony\Component\Validator\Constraints\UrlValidator;
1716
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1817

19-
/**
20-
* @group dns-sensitive
21-
*/
2218
class UrlValidatorTest extends ConstraintValidatorTestCase
2319
{
2420
protected function createValidator()
@@ -283,108 +279,6 @@ public function getValidCustomUrls()
283279
['git://[::1]/'],
284280
];
285281
}
286-
287-
/**
288-
* @dataProvider getCheckDns
289-
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
290-
* @group legacy
291-
* @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1. Its false-positive rate is too high to be relied upon.
292-
*/
293-
public function testCheckDns($violation)
294-
{
295-
DnsMock::withMockedHosts(['example.com' => [['type' => $violation ? '' : 'A']]]);
296-
297-
$constraint = new Url([
298-
'checkDNS' => 'ANY',
299-
'dnsMessage' => 'myMessage',
300-
]);
301-
302-
$this->validator->validate('http://example.com', $constraint);
303-
304-
if (!$violation) {
305-
$this->assertNoViolation();
306-
} else {
307-
$this->buildViolation('myMessage')
308-
->setParameter('{{ value }}', '"example.com"')
309-
->setCode(Url::INVALID_URL_ERROR)
310-
->assertRaised();
311-
}
312-
}
313-
314-
public function getCheckDns()
315-
{
316-
return [[true], [false]];
317-
}
318-
319-
/**
320-
* @dataProvider getCheckDnsTypes
321-
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
322-
* @group legacy
323-
* @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1. Its false-positive rate is too high to be relied upon.
324-
*/
325-
public function testCheckDnsByType($type)
326-
{
327-
DnsMock::withMockedHosts(['example.com' => [['type' => $type]]]);
328-
329-
$constraint = new Url([
330-
'checkDNS' => $type,
331-
'dnsMessage' => 'myMessage',
332-
]);
333-
334-
$this->validator->validate('http://example.com', $constraint);
335-
336-
$this->assertNoViolation();
337-
}
338-
339-
public function getCheckDnsTypes()
340-
{
341-
return [
342-
['ANY'],
343-
['A'],
344-
['A6'],
345-
['AAAA'],
346-
['CNAME'],
347-
['MX'],
348-
['NAPTR'],
349-
['NS'],
350-
['PTR'],
351-
['SOA'],
352-
['SRV'],
353-
['TXT'],
354-
];
355-
}
356-
357-
/**
358-
* @expectedException \Symfony\Component\Validator\Exception\InvalidOptionsException
359-
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
360-
* @group legacy
361-
* @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1. Its false-positive rate is too high to be relied upon.
362-
* @expectedDeprecation The "dnsMessage" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1.
363-
*/
364-
public function testCheckDnsWithInvalidType()
365-
{
366-
DnsMock::withMockedHosts(['example.com' => [['type' => 'A']]]);
367-
368-
$constraint = new Url([
369-
'checkDNS' => 'BOGUS',
370-
'dnsMessage' => 'myMessage',
371-
]);
372-
373-
$this->validator->validate('http://example.com', $constraint);
374-
}
375-
376-
/**
377-
* @group legacy
378-
* @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1. Its false-positive rate is too high to be relied upon.
379-
*/
380-
public function testCheckDnsOptionIsDeprecated()
381-
{
382-
$constraint = new Url([
383-
'checkDNS' => Url::CHECK_DNS_TYPE_NONE,
384-
]);
385-
386-
$this->validator->validate('http://example.com', $constraint);
387-
}
388282
}
389283

390284
class EmailProvider

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.