Skip to content

Commit 5c8366b

Browse files
committed
bug #24589 Username and password in basic auth are allowed to contain '.' (Richard Quadling)
This PR was merged into the 2.7 branch. Discussion ---------- Username and password in basic auth are allowed to contain '.' Initially reported by Fede Isas in beberlei/assert#234 | Q | A | ------------- | --- | Branch? | 2.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- e5d57dd050 Username and password in basic auth are allowed to contain '.'
2 parents ca09803 + 3444e5d commit 5c8366b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Tests/Constraints/UrlValidatorTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ public function getValidUrls()
121121
array('http://xn--d1abbgf6aiiy.xn--p1ai/'),
122122
array('http://☎.com/'),
123123
array('http://username:password@symfony.com'),
124+
array('http://user.name:password@symfony.com'),
125+
array('http://username:pass.word@symfony.com'),
126+
array('http://user.name:pass.word@symfony.com'),
124127
array('http://user-name@symfony.com'),
125128
array('http://symfony.com?'),
126129
array('http://symfony.com?query=1'),

0 commit comments

Comments
 (0)