Skip to content

Commit ad89564

Browse files
committed
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 ------- c9c7a11 [Validator] Accept underscores in the URL validator as the URL will resolve correctly
2 parents 8dc0814 + c9c7a11 commit ad89564

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class UrlValidator extends ConstraintValidator
2525
(%s):// # protocol
2626
(([\.\pL\pN-]+:)?([\.\pL\pN-]+)@)? # basic auth
2727
(
28-
([\pL\pN\pS\-\.])+(\.?([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
28+
([\pL\pN\pS\-\_\.])+(\.?([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
2929
| # or
3030
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # an IP address
3131
| # or

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public function getValidUrls()
7272
['http://www.example.museum'],
7373
['https://example.com/'],
7474
['https://example.com:80/'],
75+
['http://examp_le.com'],
76+
['http://www.sub_domain.examp_le.com'],
7577
['http://www.example.coop/'],
7678
['http://www.test-example.com/'],
7779
['http://www.symfony.com/'],
@@ -152,7 +154,6 @@ public function getInvalidUrls()
152154
['://example.com'],
153155
['http ://example.com'],
154156
['http:/example.com'],
155-
['http://examp_le.com'],
156157
['http://example.com::aa'],
157158
['http://example.com:aa'],
158159
['ftp://example.fr'],

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy