8000 bug #43388 [Validator] Fixes URL validation for single-char subdomain… · symfony/symfony@27b1153 · GitHub
[go: up one dir, main page]

Skip to content

Commit 27b1153

Browse files
committed
bug #43388 [Validator] Fixes URL validation for single-char subdomains (DfKimera)
This PR was merged into the 4.4 branch. Discussion ---------- [Validator] Fixes URL validation for single-char subdomains | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #43038 | License | MIT | Doc PR | This fixes an issue with failing validations for valid URLs that have a single char in subdomains. This bug was originally introduced on this commit: 074539d Some additional test cases with this scenario for valid and invalid URLs were added. Commits ------- d28c3ff bug #43038 [Validator] Fixes URL validation for single-char subdomains.
2 parents ab7884c + d28c3ff commit 27b1153

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class UrlValidator extends ConstraintValidator
2626
(%s):// # protocol
2727
(((?:[\_\.\pL\pN-]|%%[0-9A-Fa-f]{2})+:)?((?:[\_\.\pL\pN-]|%%[0-9A-Fa-f]{2})+)@)? # basic auth
2828
(
29-
([\pL\pN\pS]+\.?[\pL\pN\pS\-\_]+)+(\.?([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
29+
([\pL\pN\pS\-\_]+\.)*(([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
3030
| # or
3131
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # an IP address
3232
| # or

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ public function getValidUrls()
106106
['http://a.pl'],
107107
['http://www.example.com'],
108108
['http://tt.example.com'],
109+
['http://m.example.com'],
110+
['http://m.m.m.example.com'],
111+
['http://example.m.example.com'],
112+
['https://long-string_with+symbols.m.example.com'],
109113
['http://www.example.com.'],
110114
['http://www.example.museum'],
111115
['https://example.com/'],
@@ -268,6 +272,8 @@ public function getInvalidUrls()
268272
['http://'],
269273
['http://www..com'],
270274
['http://www..example.com'],
275+
['http://www..m.example.com'],
276+
['http://.m.example.com'],
271277
['http://wwww.example..com'],
272278
['http://.www.example.com'],
273279
];

0 commit comments

Comments
 (0)
0