Skip to content

Commit f3eeb40

Browse files
Merge branch '4.4' into 5.3
* 4.4: [Validator] Fix validation for single level domains Increased the reserved memory from 10k to 32k [DoctrineBridge] Add DbalLoggerTest to group legacy
2 parents 14c9458 + 9800a5b commit f3eeb40

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

Constraints/UrlValidator.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ class UrlValidator extends ConstraintValidator
2525
(%s):// # protocol
2626
(((?:[\_\.\pL\pN-]|%%[0-9A-Fa-f]{2})+:)?((?:[\_\.\pL\pN-]|%%[0-9A-Fa-f]{2})+)@)? # basic auth
2727
(
28-
([\pL\pN\pS\-\_]+\.)*(([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
28+
(?:
29+
(?:xn--[a-z0-9-]++\.)*+xn--[a-z0-9-]++ # a domain name using punycode
30+
|
31+
(?:[\pL\pN\pS\pM\-\_]++\.)+[\pL\pN\pM]++ # a multi-level domain name
32+
|
33+
[a-z0-9\-\_]++ # a single-level domain name
34+
)\.?
2935
| # or
3036
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # an IP address
3137
| # or

Tests/Constraints/UrlValidatorTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ public function getValidUrls()
123123
['http://very.long.domain.name.com/'],
124124
['http://localhost/'],
125125
['http://myhost123/'],
126+
['http://internal-api'],
127+
['http://internal-api.'],
128+
['http://internal-api/'],
129+
['http://internal-api/path'],
126130
['http://127.0.0.1/'],
127131
['http://127.0.0.1:80/'],
128132
['http://[::1]/'],
@@ -169,6 +173,7 @@ public function getValidUrls()
169173
['http://symfony.com/#fragment'],
170174
['http://symfony.com/#one_more%20test'],
171175
['http://example.com/exploit.html?hello[0]=test'],
176+
['http://বিডিআইএ.বাংলা'],
172177
];
173178
}
174179

@@ -254,7 +259,14 @@ public function getInvalidUrls()
254259
['http://127.0.0.1:aa/'],
255260
['ftp://[::1]/'],
256261
['http://[::1'],
262+
['http://☎'],
263+
['http://☎.'],
264+
['http://☎/'],
265+
['http://☎/path'],
266+
['http://hello.☎'],
267+
['http://hello.☎.'],
257268
['http://hello.☎/'],
269+
['http://hello.☎/path'],
258270
['http://:[email protected]'],
259271
['http://:password@@symfony.com'],
260272
['http://username:passwordsymfony.com'],
@@ -271,6 +283,9 @@ public function getInvalidUrls()
271283
['http://.m.example.com'],
272284
['http://wwww.example..com'],
273285
['http://.www.example.com'],
286+
['http://example.co-'],
287+
['http://example.co-/path'],
288+
['http:///path'],
274289
];
275290
}
276291

0 commit comments

Comments
 (0)