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

Skip to content

Commit ffcb691

Browse files
committed
bug #34832 [3.4][Validator] Allow underscore character "_" in URL username and password (romainneutron)
This PR was merged into the 3.4 branch. Discussion ---------- [3.4][Validator] Allow underscore character "_" in URL username and password | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT Hello! It's been a long time since my last push on Symfony :) Here's a bug fix. I think URL usernames and password may contain an underscore. Let me know! Commits ------- 869518b [Validator] Allow underscore character "_" in URL username and password
2 parents 59126e0 + 869518b commit ffcb691

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)