From b720bedf7254eb440c1d66197a60530a4ccbb715 Mon Sep 17 00:00:00 2001 From: hoellen Date: Wed, 14 Aug 2019 01:21:25 +0200 Subject: [PATCH] Support domain literals for receiving emails --- core/admin/mailu/internal/views/postfix.py | 5 ++++- towncrier/newsfragments/1087.bugfix | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 towncrier/newsfragments/1087.bugfix diff --git a/core/admin/mailu/internal/views/postfix.py b/core/admin/mailu/internal/views/postfix.py index 0b229825..21a4aa91 100644 --- a/core/admin/mailu/internal/views/postfix.py +++ b/core/admin/mailu/internal/views/postfix.py @@ -2,10 +2,13 @@ from mailu import models from mailu.internal import internal import flask +import re @internal.route("/postfix/domain/") def postfix_mailbox_domain(domain_name): + if re.match("^\[.*\]$", domain_name): + return flask.abort(404) domain = models.Domain.query.get(domain_name) or \ models.Alternative.query.get(domain_name) or \ flask.abort(404) @@ -29,7 +32,7 @@ def postfix_alias_map(alias): @internal.route("/postfix/transport/") def postfix_transport(email): - if email == '*': + if email == '*' or re.match("(^|.*@)\[.*\]$", email): return flask.abort(404) localpart, domain_name = models.Email.resolve_domain(email) relay = models.Relay.query.get(domain_name) or flask.abort(404) diff --git a/towncrier/newsfragments/1087.bugfix b/towncrier/newsfragments/1087.bugfix new file mode 100644 index 00000000..fdd815bb --- /dev/null +++ b/towncrier/newsfragments/1087.bugfix @@ -0,0 +1 @@ +Support domain literals