Skip to content

fix: keep checking MX hosts after an unlisted host with one dot - #330

Open
mebezac wants to merge 1 commit into
micke:mainfrom
mebezac:fix/disposable-mx-two-label-host
Open

mebezac wants to merge 1 commit into
micke:mainfrom
mebezac:fix/disposable-mx-two-label-host

Conversation

@mebezac

@mebezac mebezac commented Nov 3, 2026

Copy link
Copy Markdown

disposable? can return the wrong answer when a domain has more than one MX record.

The problem

domain_is_in? checks each MX host in a loop. Some MX hosts have a short name with one dot, for example ordinary.example. If that host is not on the list, the method uses return false. In Ruby, return inside a block stops the whole method. So the method does not check the other MX hosts.

How to see it

A domain has these MX records, in this order:

  1. ordinary.example
  2. emailfake.com (this is on the disposable list)

disposable? returns false. If you swap the order, it returns true.

The fix

Change return false to next false. Now the loop goes on to the next host.

I added two specs, one for each order. The first spec fails without the fix.

domain_is_in? checks each MX host in an any? loop. For a short host
name with one dot (for example ordinary.example) that is not on the
list, it used `return false`. In Ruby, `return` inside a block stops
the whole method, so the other MX hosts were never checked. Use
`next false` so the loop goes on to the next host.
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.

1 participant