8000 [Validator] Accept underscores in the URL validator as the URL will r… · symfony/symfony@c9c7a11 · GitHub
[go: up one dir, main page]

Skip to content

Commit c9c7a11

Browse files
battyenicolas-grekas
authored andcommitted
[Validator] Accept underscores in the URL validator as the URL will resolve correctly
1 parent ad66a16 commit c9c7a11

File tree

2 files changed

+3
-2
lines changed
< 10000 span role="tooltip" aria-label="Collapse file tree" id="expand-button-file-tree-button" class="Tooltip__TooltipBase-sc-17tf59c-0 hWlpPn tooltipped-se">

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)
0