[Validator] Allow underscore character "_" in URL username and password

This commit is contained in:
Romain Neutron 2019-12-05 15:02:34 +01:00
parent 59126e0f9c
commit 869518bc7e
No known key found for this signature in database
GPG Key ID: 201FC7CF9F0CA3ED
2 changed files with 3 additions and 1 deletions

View File

@ -23,7 +23,7 @@ class UrlValidator extends ConstraintValidator
{
const PATTERN = '~^
(%s):// # protocol
(([\.\pL\pN-]+:)?([\.\pL\pN-]+)@)? # basic auth
(([\_\.\pL\pN-]+:)?([\_\.\pL\pN-]+)@)? # basic auth
(
([\pL\pN\pS\-\_\.])+(\.?([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
| # or

View File

@ -117,9 +117,11 @@ class UrlValidatorTest extends ConstraintValidatorTestCase
['http://☎.com/'],
['http://username:password@symfony.com'],
['http://user.name:password@symfony.com'],
['http://user_name:pass_word@symfony.com'],
['http://username:pass.word@symfony.com'],
['http://user.name:pass.word@symfony.com'],
['http://user-name@symfony.com'],
['http://user_name@symfony.com'],
['http://symfony.com?'],
['http://symfony.com?query=1'],
['http://symfony.com/?query=1'],