[Validator] allow brackets in the optional query string

This commit is contained in:
Emmanuel BORGES 2019-03-19 17:21:05 +01:00 committed by Fabien Potencier
parent 19c6639452
commit 40dc4c89df
2 changed files with 4 additions and 3 deletions

View File

@ -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';
/**

View File

@ -151,6 +151,7 @@ class UrlValidatorTest extends ConstraintValidatorTestCase
['http://symfony.com#fragment'],
['http://symfony.com/#fragment'],
['http://symfony.com/#one_more%20test'],
['http://example.com/exploit.html?hello[0]=test'],
];
}