Skip to content

Support null MX and SRV records that use the root label - #125

Merged
freekmurze merged 2 commits into
spatie:mainfrom
mattiasgeniar:support-root-domain-label
Jun 16, 2026
Merged

Support null MX and SRV records that use the root label#125
freekmurze merged 2 commits into
spatie:mainfrom
mattiasgeniar:support-root-domain-label

Conversation

@mattiasgeniar

@mattiasgeniar mattiasgeniar commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Parsing a null MX (RFC 7505) or a service-declining SRV (RFC 2782) threw InvalidArgument::domainIsMissing, because the root label . was fed to Domain as an empty host. Both are valid records that appear in the wild:

example.com.            3600    IN      MX      0 .
_sip._tcp.example.com.  3600    IN      SRV     0 0 0 .

This PR allows the package to parse and round-trip them instead of rejecting them.

A null MX ("0 .", RFC 7505) and an SRV record that declines a service
("0 0 0 .", RFC 2782) carry the root label as their target. prepareDomain
rejected it because the dot-stripped root is an empty string, which the
Domain helper treats as a missing domain, so these valid records threw and
were silently dropped during parsing. Represent the root as an empty string,
consistent with how every other domain value is stored dot-stripped and has
its trailing dot re-appended by __toString. The query path stays strict.
@mattiasgeniar
mattiasgeniar marked this pull request as draft June 11, 2026 17:52
@mattiasgeniar
mattiasgeniar marked this pull request as ready for review June 11, 2026 19:11
@freekmurze
freekmurze merged commit f600615 into spatie:main Jun 16, 2026
8 checks passed
@freekmurze

Copy link
Copy Markdown
Member

Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants