Skip to content

Navigation Menu

Sign in
Appearance settings

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 c9c7a11

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

File tree

2 files changed

+3
-2
lines changed
Filter options

2 files changed

+3
-2
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/UrlValidator.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php
+2-1Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.