Matching: domains are cut to their last two labels, so any .co.uk sender matches a .co.uk company #19
Labels
No labels
bug
documentation
enhancement
performance
security
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Postulo/postulo-imap#19
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found on 2026-09-29 in a read-only review of postulo-imap at
cc09c6381, runningregistrableandmatchwith hosts under two-label public suffixes.registrable()takes the last two labels of a host as the organisation. Under a two-label public suffix (co.uk,com.br,com.pl,com.au,co.jp,ac.uk,org.ukand the like) those two labels are the suffix itself, so the sender's domain and every company website under the same suffix compare equal. The result is reported as matched by domain, the second strongest signal after a recorded contact.Where:
src/postulo_imap/matching.py:56-60,registrable:".".join(parts[-2:]); its docstring says the last two labels are "enough to tell one organisation from another".src/postulo_imap/matching.py:117-126,match, step 3:domain = registrable(mail.domain), thendomain not in PUBLIC_DOMAINS, then the comparison withdomain_of(application.posting.company.website).src/postulo_imap/matching.py:35:"yahoo.co.uk"inPUBLIC_DOMAINS. The check is made on the reduced value, which for that address isco.uk, so this entry can never match.tests/test_imap.py:391-394,test_a_domain_is_reduced_to_the_organisation: onlyblackmesa.test.What happens: run on the snapshot with one open application at a company whose website is
https://www.acme.co.uk:registrable("careers.acme.co.uk")→co.uk;registrable("mail.yahoo.com.br")→com.br;"co.uk" in PUBLIC_DOMAINS→False.recruiter@otherfirm.co.uk→ matched to Acme, howdomain.jane.doe@yahoo.co.uk→ matched to Acme, howdomain..co.ukcompany, mail fromhr@acme.co.uk→ no match: the genuine one is discarded as ambiguous (_only,src/postulo_imap/matching.py:71-76), and the weaker name search decides.The same reduction also equates everything under a hosting suffix (
domain_of("https://acme.github.io")→github.io). A website typed with non-ASCII letters is compared as typed (domain_of("https://münchen.example")→münchen.example) while a sender's domain arrives in itsxn--form, so those never match.Why it matters: a person with one open application in the United Kingdom, Brazil, Poland (
.com.pl), Australia or Japan gets every recognised message from any other organisation under that suffix, privateyahoo.co.ukaddresses included, attached to that application with Matched by: domain. Accepting the suggestion writes the event, and for a rejection or an offer the status, onto the wrong application. The README says "public mail providers prove nothing and are ignored" (README.md:50-52).Fix:
tldextract,publicsuffixlist), use only its bundled snapshot:tldextractdownloads the list on first use unless it is built withsuffix_list_urls=(), and a plugin must not make an outbound request of its own. A short built-in table of the common two-label suffixes is the alternative if no dependency is wanted.PUBLIC_DOMAINSbefore comparing.Done when
tests/test_imap.pyhas tests thatregistrable("careers.acme.co.uk")isacme.co.ukandregistrable("vagas.acme.com.br")isacme.com.br; that mail from another.co.ukorganisation and from ayahoo.co.ukaddress is not matched by domain to an application at a.co.ukcompany; and that with two applications at different.co.ukcompanies, mail from one of them is matched to it by domain. All fail today.Fixed by pull request #25.