8000 [Validator] Allow an empty path in a URL with only a fragment or a query · symfony/symfony@b3a5411 · GitHub
[go: up one dir, main page]

Skip to content

Commit b3a5411

Browse files
committed
[Validator] Allow an empty path in a URL with only a fragment or a query
1 parent 751f2be commit b3a5411

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class UrlValidator extends ConstraintValidator
3333
\] # a IPv6 address
3434
)
3535
(:[0-9]+)? # a port (optional)
36-
(/?|/\S+) # a /, nothing or a / with something
36+
(/?|/\S+|\?|\#) # a /, nothing, a / with something, a query or a fragment
3737
$~ixu';
3838

3939
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ public function getValidUrls()
111111
array('http://☎.com/'),
112112
array('http://username:password@symfony.com'),
113113
array('http://user-name@symfony.com'),
114+
array('http://symfony.com?'),
115+
array('http://symfony.com#'),
114116
);
115117
}
116118

@@ -140,8 +142,6 @@ public function getInvalidUrls()
140142
array('http://goog_le.com'),
141143
array('http://google.com::aa'),
142144
array('http://google.com:aa'),
143-
array('http://symfony.com?'),
144-
array('http://symfony.com#'),
145145
array('ftp://google.fr'),
146146
array('faked://google.fr'),
147147
array('http://127.0.0.1:aa/'),

0 commit comments

Comments
 (0)
0