From 79ca39a6256970b2e3a2c906e3dd268323a0fd0d Mon Sep 17 00:00:00 2001 From: Son Date: Tue, 14 Dec 2021 15:00:27 +0100 Subject: [PATCH] use regex_match instead of re.fullmatch() --- app/alias_utils.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/alias_utils.py b/app/alias_utils.py index 676611ae..3f3ef51a 100644 --- a/app/alias_utils.py +++ b/app/alias_utils.py @@ -1,6 +1,6 @@ +import re from typing import Optional -import re2 as re from email_validator import validate_email, EmailNotValidError from sqlalchemy.exc import IntegrityError, DataError @@ -27,8 +27,8 @@ from app.models import ( Mailbox, EmailLog, Contact, - AutoCreateRule, ) +from app.regex_utils import regex_match def try_auto_create(address: str) -> Optional[Alias]: @@ -139,9 +139,7 @@ def try_auto_create_via_domain(address: str) -> Optional[Alias]: local = get_email_local_part(address) for rule in custom_domain.auto_create_rules: - rule: AutoCreateRule - regex = re.compile(rule.regex) - if re.fullmatch(regex, local): + if regex_match(rule.regex, local): LOG.d( "%s passes %s on %s", address,