bug #32522 [Validator] Accept underscores in the URL validator, as the URL will load (battye)
This PR was merged into the 3.4 branch.
Discussion
----------
[Validator] Accept underscores in the URL validator, as the URL will load
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #32506
| License | MIT
| Doc PR | -
As @javiereguiluz mentioned, regardless of convention a URL with an underscore in it will load perfectly fine - so in that respect it must be valid.
Commits
-------
c9c7a1118c
[Validator] Accept underscores in the URL validator as the URL will resolve correctly
This commit is contained in:
commit
ad89564ebf
@ -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
|
||||
|
@ -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'],
|
||||
|
Reference in New Issue
Block a user