8000 [Validator] Allow underscore character "_" in URL username and password · symfony/symfony@869518b · GitHub
[go: up one dir, main page]

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:password@symfony.com'],
119119
['http://user.name:password@symfony.com'],
120+
['http://user_name:pass_word@symfony.com'],
120121
['http://username:pass.word@symfony.com'],
121122
['http://user.name:pass.word@symfony.com'],
122123
['http://user-name@symfony.com'],
124+
['http://user_name@symfony.com'],
123125
['http://symfony.com?'],
124126
['http://symfony.com?query=1'],
125127
['http://symfony.com/?query=1'],

0 commit comments

Comments
 (0)
0