Skip to content

Commit

Permalink
[Validator] allow brackets in the optional query string
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel BORGES authored and fabpot committed Mar 27, 2019
1 parent f463ca7 commit f12904d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Constraints/UrlValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class UrlValidator extends ConstraintValidator
\] # an IPv6 address
)
(:[0-9]+)? # a port (optional)
(?:/ (?:[\pL\pN\-._\~!$&\'()*+,;=:@]|%%[0-9A-Fa-f]{2})* )* # a path
(?:\? (?:[\pL\pN\-._\~!$&\'()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a query (optional)
(?:\# (?:[\pL\pN\-._\~!$&\'()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a fragment (optional)
(?:/ (?:[\pL\pN\-._\~!$&\'()*+,;=:@]|%%[0-9A-Fa-f]{2})* )* # a path
(?:\? (?:[\pL\pN\-._\~!$&\'\[\]()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a query (optional)
(?:\# (?:[\pL\pN\-._\~!$&\'()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a fragment (optional)
$~ixu';

/**
Expand Down
1 change: 1 addition & 0 deletions Tests/Constraints/UrlValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public function getValidUrls()
['http://symfony.com#fragment'],
['http://symfony.com/#fragment'],
['http://symfony.com/#one_more%20test'],
['http://example.com/exploit.html?hello[0]=test'],
];
}

Expand Down

0 comments on commit f12904d

Please sign in to comment.