1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2026-03-18 18:07:22 +01:00

Fixed EM101 (raw-string-in-exception): Exception must not use a string literal, assign to variable first

This commit is contained in:
Teal Dulcet
2023-12-22 07:10:48 -08:00
committed by Joshua Tauberer
parent 49124cc9ca
commit dd61844ced
7 changed files with 42 additions and 21 deletions

View File

@@ -919,7 +919,8 @@ def set_custom_dns_record(qname, rtype, value, action, env):
rtype = rtype.upper()
if value is not None and qname != "_secondary_nameserver":
if not re.search(DOMAIN_RE, qname):
raise ValueError("Invalid name.")
msg = "Invalid name."
raise ValueError(msg)
if rtype in {"A", "AAAA"}:
if value != "local": # "local" is a special flag for us
@@ -928,14 +929,16 @@ def set_custom_dns_record(qname, rtype, value, action, env):
if rtype == "AAAA" and not isinstance(v, ipaddress.IPv6Address): raise ValueError("That's an IPv4 address.")
elif rtype in {"CNAME", "NS"}:
if rtype == "NS" and qname == zone:
raise ValueError("NS records can only be set for subdomains.")
msg = "NS records can only be set for subdomains."
raise ValueError(msg)
# ensure value has a trailing dot
if not value.endswith("."):
value = value + "."
if not re.search(DOMAIN_RE, value):
raise ValueError("Invalid value.")
msg = "Invalid value."
raise ValueError(msg)
elif rtype in {"CNAME", "TXT", "SRV", "MX", "SSHFP", "CAA"}:
# anything goes
pass