Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 869518b

Browse files
committed
[Validator] Allow underscore character "_" in URL username and password
1 parent 59126e0 commit 869518b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class UrlValidator extends ConstraintValidator
2323
{
2424
const PATTERN = '~^
2525
(%s):// # protocol
26-
(([\.\pL\pN-]+:)?([\.\pL\pN-]+)@)? # basic auth
26+
(([\_\.\pL\pN-]+:)?([\_\.\pL\pN-]+)@)? # basic auth
2727
(
2828
([\pL\pN\pS\-\_\.])+(\.?([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
2929
| # or

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ public function getValidUrls()
117117
['http://☎.com/'],
118118
['http://username:[email protected]'],
119119
['http://user.name:[email protected]'],
120+
['http://user_name:[email protected]'],
120121
['http://username:[email protected]'],
121122
['http://user.name:[email protected]'],
122123
['http://[email protected]'],
124+
['http://[email protected]'],
123125
['http://symfony.com?'],
124126
['http://symfony.com?query=1'],
125127
['http://symfony.com/?query=1'],

0 commit comments

Comments
 (0)