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

Skip to content

Commit 71c33c1

Browse files
committed
feature #30606 [Validator] allow brackets in the optional query string (Emmanuel BORGES)
This PR was squashed before being merged into the 4.3-dev branch (closes #30606). Discussion ---------- [Validator] allow brackets in the optional query string | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #30603 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Add the `allowBrackets` option from the Url constraint to allow brackets in the optional query string. Commits ------- 40dc4c8 [Validator] allow brackets in the optional query string
2 parents 91b0afa + 40dc4c8 commit 71c33c1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Symfony/Component/Validator/Constraints/UrlValidator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class UrlValidator extends ConstraintValidator
3535
\] # an IPv6 address
3636
)
3737
(:[0-9]+)? # a port (optional)
38-
(?:/ (?:[\pL\pN\-._\~!$&\'()*+,;=:@]|%%[0-9A-Fa-f]{2})* )* # a path
39-
(?:\? (?:[\pL\pN\-._\~!$&\'()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a query (optional)
40-
(?:\# (?:[\pL\pN\-._\~!$&\'()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a fragment (optional)
38+
(?:/ (?:[\pL\pN\-._\~!$&\'()*+,;=:@]|%%[0-9A-Fa-f]{2})* )* # a path
39+
(?:\? (?:[\pL\pN\-._\~!$&\'\[\]()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a query (optional)
40+
(?:\# (?:[\pL\pN\-._\~!$&\'()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a fragment (optional)
4141
$~ixu';
4242

4343
/**

src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ public function getValidUrls()
151151
['http://symfony.com#fragment'],
152152
['http://symfony.com/#fragment'],
153153
['http://symfony.com/#one_more%20test'],
154+
['http://example.com/exploit.html?hello[0]=test'],
154155
];
155156
}
156157

0 commit comments

Comments
 (0)