From c9c7a1118c2ccce9e0afe414344fbfdb4bdd1de0 Mon Sep 17 00:00:00 2001 From: battye Date: Fri, 12 Jul 2019 15:57:23 +0000 Subject: [PATCH] [Validator] Accept underscores in the URL validator as the URL will resolve correctly --- src/Symfony/Component/Validator/Constraints/UrlValidator.php | 2 +- .../Component/Validator/Tests/Constraints/UrlValidatorTest.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/UrlValidator.php b/src/Symfony/Component/Validator/Constraints/UrlValidator.php index bdaef756bc..b77701dd7e 100644 --- a/src/Symfony/Component/Validator/Constraints/UrlValidator.php +++ b/src/Symfony/Component/Validator/Constraints/UrlValidator.php @@ -25,7 +25,7 @@ class UrlValidator extends ConstraintValidator (%s):// # protocol (([\.\pL\pN-]+:)?([\.\pL\pN-]+)@)? # basic auth ( - ([\pL\pN\pS\-\.])+(\.?([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name + ([\pL\pN\pS\-\_\.])+(\.?([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name | # or \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # an IP address | # or diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php index ab845d45db..f04dd44bc9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php @@ -72,6 +72,8 @@ class UrlValidatorTest extends ConstraintValidatorTestCase ['http://www.example.museum'], ['https://example.com/'], ['https://example.com:80/'], + ['http://examp_le.com'], + ['http://www.sub_domain.examp_le.com'], ['http://www.example.coop/'], ['http://www.test-example.com/'], ['http://www.symfony.com/'], @@ -152,7 +154,6 @@ class UrlValidatorTest extends ConstraintValidatorTestCase ['://example.com'], ['http ://example.com'], ['http:/example.com'], - ['http://examp_le.com'], ['http://example.com::aa'], ['http://example.com:aa'], ['ftp://example.fr'],