This commit is contained in:
Renaud Boyer 2020-12-06 22:11:58 +01:00
parent f2f13958c7
commit 5d948faf56
9 changed files with 20 additions and 15 deletions

View file

@ -31,7 +31,7 @@ def email_validator():
if "<" in email and ">" in email:
if email.find("<") + 1 < email.find(">"):
email_part = email[email.find("<") + 1:email.find(">")].strip()
email_part = email[email.find("<") + 1 : email.find(">")].strip()
if not is_valid_email(email_part):
raise ValidationError(message)

View file

@ -35,10 +35,10 @@ def custom_domain():
new_domain = new_custom_domain_form.domain.data.lower().strip()
if new_domain.startswith("http://"):
new_domain = new_domain[len("http://"):]
new_domain = new_domain[len("http://") :]
if new_domain.startswith("https://"):
new_domain = new_domain[len("https://"):]
new_domain = new_domain[len("https://") :]
if SLDomain.get_by(domain=new_domain):
flash("A custom domain cannot be a built-in domain.", "error")

View file

@ -199,7 +199,9 @@ def mailbox_detail_route(mailbox_id):
def verify_mailbox_change(user, mailbox, new_email):
s = Signer(MAILBOX_SECRET)
mailbox_id_signed = s.sign(str(mailbox.id)).decode()
verification_url = f"{URL}/dashboard/mailbox/confirm_change?mailbox_id={mailbox_id_signed}"
verification_url = (
f"{URL}/dashboard/mailbox/confirm_change?mailbox_id={mailbox_id_signed}"
)
send_email(
new_email,

View file

@ -74,7 +74,7 @@ def get_spf_domain(hostname) -> [str]:
parts = record.split(" ")
for part in parts:
if part.startswith(_include_spf):
ret.append(part[part.find(_include_spf) + len(_include_spf):])
ret.append(part[part.find(_include_spf) + len(_include_spf) :])
return ret

View file

@ -246,7 +246,7 @@ def send_email(
)
# add DKIM
email_domain = SUPPORT_EMAIL[SUPPORT_EMAIL.find("@") + 1:]
email_domain = SUPPORT_EMAIL[SUPPORT_EMAIL.find("@") + 1 :]
add_dkim_signature(msg, email_domain)
msg_raw = to_bytes(msg)
@ -343,7 +343,7 @@ def get_email_domain_part(address):
Get the domain part from email
ab@cd.com -> cd.com
"""
return address[address.find("@") + 1:].strip().lower()
return address[address.find("@") + 1 :].strip().lower()
def add_dkim_signature(msg: Message, email_domain: str):
@ -362,7 +362,7 @@ def add_dkim_signature(msg: Message, email_domain: str):
# remove linebreaks from sig
sig = sig.replace("\n", " ").replace("\r", "")
msg["DKIM-Signature"] = sig[len("DKIM-Signature: "):]
msg["DKIM-Signature"] = sig[len("DKIM-Signature: ") :]
def add_or_replace_header(msg: Message, header: str, value: str):
@ -518,7 +518,7 @@ def get_header_from_bounce(msg: Message, header: str) -> str:
r = re.search(exp, msg_str)
if r:
# substr should be something like 'HEADER: 1234'
substr = msg_str[r.start():r.end()].strip()
substr = msg_str[r.start() : r.end()].strip()
parts = substr.split(":")
return parts[1].strip()
@ -570,9 +570,9 @@ def get_spam_from_header(spam_status_header, max_score=None) -> (bool, str):
# spam score
# get the score section "score=-0.1"
score_section = (
spam_status_header[spam_status_header.find(",") + 1:].strip().split(" ")[0]
spam_status_header[spam_status_header.find(",") + 1 :].strip().split(" ")[0]
)
score = float(score_section[len("score="):])
score = float(score_section[len("score=") :])
if score >= max_score:
LOG.warning("Spam score %s exceeds %s", score, max_score)
return True, spam_status_header

View file

@ -74,7 +74,7 @@ class SpamAssassin(object):
first_line = match.group(1)
headers = match.group(2)
body = response[match.end(0):]
body = response[match.end(0) :]
# Checking response is good
match = first_line_pattern.match(first_line)
@ -87,7 +87,7 @@ class SpamAssassin(object):
s.strip() for s in body.decode("utf-8", errors="ignore").strip().split("\n")
]
linebreak_num = report_list.index([s for s in report_list if "---" in s][0])
tablelists = [s for s in report_list[linebreak_num + 1:]]
tablelists = [s for s in report_list[linebreak_num + 1 :]]
self.report_fulltext = "\n".join(report_list)

View file

@ -418,7 +418,9 @@ def sanity_check():
def check_custom_domain():
LOG.d("Check verified domain for DNS issues")
for custom_domain in CustomDomain.query.filter_by(verified=True): # type: CustomDomain
for custom_domain in CustomDomain.query.filter_by(
verified=True
): # type: CustomDomain
mx_domains = get_mx_domains(custom_domain.domain)
if sorted(mx_domains) != sorted(EMAIL_SERVERS_WITH_PRIORITY):

View file

@ -779,7 +779,7 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str):
alias = contact.alias
address: str = contact.alias.email
alias_domain = address[address.find("@") + 1:]
alias_domain = address[address.find("@") + 1 :]
# Sanity check: verify alias domain is managed by SimpleLogin
# scenario: a user have removed a domain but due to a bug, the aliases are still there

View file

@ -1,4 +1,5 @@
import os
# flake8: noqa: E402
os.environ["CONFIG"] = os.path.abspath(