[Validator] Accept underscores in the URL validator as the URL will resolve correctly

This commit is contained in:
battye 2019-07-12 15:57:23 +00:00 committed by Nicolas Grekas
parent ad66a160b1
commit c9c7a1118c
2 changed files with 3 additions and 2 deletions

View File

@ -25,7 +25,7 @@ class UrlValidator extends ConstraintValidator
(%s):// # protocol
(([\.\pL\pN-]+:)?([\.\pL\pN-]+)@)? # basic auth
(
([\pL\pN\pS\-\.])+(\.?([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
([\pL\pN\pS\-\_\.])+(\.?([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
| # or
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # an IP address
| # or

View File

@ -72,6 +72,8 @@ class UrlValidatorTest extends ConstraintValidatorTestCase
['http://www.example.museum'],
['https://example.com/'],
['https://example.com:80/'],
['http://examp_le.com'],
['http://www.sub_domain.examp_le.com'],
['http://www.example.coop/'],
['http://www.test-example.com/'],
['http://www.symfony.com/'],
@ -152,7 +154,6 @@ class UrlValidatorTest extends ConstraintValidatorTestCase
['://example.com'],
['http ://example.com'],
['http:/example.com'],
['http://examp_le.com'],
['http://example.com::aa'],
['http://example.com:aa'],
['ftp://example.fr'],