8000 [Validator] Allow basic auth in url when using UrlValidator. by blaugueux · Pull Request #11601 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] Allow basic auth in url when using UrlValidator. #11601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to f 8000 ile
Failed to load files.
Loading
Diff view
Diff view
Allow basic auth in url.
Improve regex. Add tests.
  • Loading branch information
Benjamin Laugueux committed Aug 7, 2014
commit c7d67efac1b90b858ca8dbbf5475b8524071f15b
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class UrlValidator extends ConstraintValidator
{
const PATTERN = '~^
(%s):// # protocol
(([\pL\pN-]+:)?([\pL\pN-]+)@)? # basic auth
(
([\pL\pN\pS-\.])+(\.?([\pL]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
| # or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public function getValidUrls()
array('http://xn--espaa-rta.xn--ca-ol-fsay5a/'),
array('http://xn--d1abbgf6aiiy.xn--p1ai/'),
array('http://☎.com/'),
array('http://username:password@symfony.com'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also add invalid ones to the correct provider to ensure user:pass, @, :pass@, :pass in the auth part are not accepted.

array('http://user-name@symfony.com'),
);
}

Expand Down Expand Up @@ -145,6 +147,10 @@ public function getInvalidUrls()
array('ftp://[::1]/'),
array('http://[::1'),
array('http://hello.☎/'),
array('http://:password@symfony.com'),
array('http://:password@@symfony.com'),
array('http://username:passwordsymfony.com'),
array('http://usern@me:password@symfony.com'),
);
}

Expand Down
0