Repository navigation
fix(Helpers): strip port before evaluating subdomain in parse_subdomain() - #10794
Merged
paulbalandan merged 1 commit intoNov 21, 2026
Merged
paulbalandan merged 1 commit into
paulbalandan merged 1 commit into
Conversation
michalsn
approved these changes
Nov 19, 2026
paulbalandan
approved these changes
Nov 20, 2026
Member
|
Please rebase |
This comment has been minimized.
This comment has been minimized.
banghamid
force-pushed
the
fix/url-helper-parse-subdomain-port
branch
from
November 20, 2026 17:33
ecf74d6 to
519eccd
Compare
parse_subdomain()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In
url_helper.php,parse_subdomain(?string $host = null)did not account for port numbers in the host string (such as when explicitly provided, or passed from$_SERVER['HTTP_HOST']).This caused several issues:
'192.168.1.1:8080') failedFILTER_VALIDATE_IPand was treated as a domain with 4 dot-separated parts, erroneously returning'192.168'as a subdomain.'example.co.uk:8080') failed matching inHostnames::TWO_PART_TLDSbecause$lastTwoPartswas'co.uk:8080', causing it to fall back to the standard 2-part removal and erroneously returning'example'as a subdomain.'api.example.co.uk:8080') returned'api.example'instead of'api'.This PR handles bracketed IPv6 literals (e.g.
'[::1]:8080') and strips single-colon port suffixes before evaluating IP addresses, localhost, and TLD boundaries inparse_subdomain(). It also adds test cases toprovideParseSubdomain()inMiscUrlTestand adds a changelog entry indocs/changelogs/v4.7.7.md.Checklist: