Skip to content

Commit 6de73af

Browse files
committed
fix email detection for user(at)domain.ch and add override for ssl expiry
1 parent dd3b96f commit 6de73af

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

overrides.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"6195": {"domain": "loetschen.ch", "reason": "Shared Lötschental admin"},
7676
"6197": {"domain": "loetschen.ch", "reason": "Shared Lötschental admin"},
7777
"6205": {"domain": "gemeinde-bettmeralp.ch", "reason": "as on website"},
78+
"6285": {"domain": "graechen.ch", "reason": "Wikidata URL incorrect (gemeinde-graechen.ch has SSL issues); actual website at gemeinde.graechen.ch, email on graechen.ch (MS365)"},
7879
"6404": {"domain": "ne.ch", "reason": "Using cantonal mail"},
7980
"6408": {"domain": "ne.ch", "reason": "Using cantonal mail"},
8081
"6413": {"domain": "ne.ch", "reason": "Using cantonal mail"},

src/mail_sovereignty/resolve.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,13 @@ def extract_email_domains(html: str) -> set[str]:
403403
domains.add(domain)
404404
break
405405

406+
for match in re.findall(r'[\w.-]+\s*[\[(]at[\])]\s*[\w.-]+\.\w+', html, re.IGNORECASE):
407+
normalized = re.sub(r'\s*[\[(]at[\])]\s*', '@', match, flags=re.IGNORECASE)
408+
if "@" in normalized:
409+
domain = normalized.split("@")[1].lower()
410+
if domain not in SKIP_DOMAINS:
411+
domains.add(domain)
412+
406413
return {d for d in domains if _is_valid_domain(d)}
407414

408415

tests/test_resolve.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,26 @@ def test_mailto_trailing_slash(self):
483483
domains = extract_email_domains(html)
484484
assert "example.org" in domains
485485

486+
def test_bracket_at_obfuscation(self):
487+
html = "gemeinde[at]graechen.ch"
488+
assert "graechen.ch" in extract_email_domains(html)
489+
490+
def test_paren_at_obfuscation(self):
491+
html = "info(at)gemeinde.ch"
492+
assert "gemeinde.ch" in extract_email_domains(html)
493+
494+
def test_bracket_at_with_spaces(self):
495+
html = "info [at] town.ch"
496+
assert "town.ch" in extract_email_domains(html)
497+
498+
def test_bracket_at_uppercase(self):
499+
html = "admin[AT]village.ch"
500+
assert "village.ch" in extract_email_domains(html)
501+
502+
def test_bracket_at_skip_domain(self):
503+
html = "user[at]example.com"
504+
assert extract_email_domains(html) == set()
505+
486506
def test_domain_label_too_long(self):
487507
"""Domains with labels > 63 chars should be filtered out."""
488508
long_label = "a" * 64

0 commit comments

Comments
 (0)