aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Limonciello <mario.limonciello@amd.com>2023-11-16 10:52:46 -0600
committerMario Limonciello <mario.limonciello@amd.com>2023-11-16 10:55:13 -0600
commitbfd5f0b9d5998a5c15e68579265a83753fc71634 (patch)
tree13fd9a92a3ac81e512c2a446d760b37f025b017a
parent8228c2222fcf5791fe5643252e4d248839c199e9 (diff)
downloadlinux-firmware-bfd5f0b9d5998a5c15e68579265a83753fc71634.tar.gz
Make email replies more resilient
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
-rwxr-xr-xcontrib/process_linux_firmware.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/contrib/process_linux_firmware.py b/contrib/process_linux_firmware.py
index ea108391..8e2eb350 100755
--- a/contrib/process_linux_firmware.py
+++ b/contrib/process_linux_firmware.py
@@ -81,6 +81,11 @@ def quiet_cmd(cmd):
def reply_email(content, branch):
+ user = None
+ password = None
+ server = None
+ port = None
+
if "SMTP_USER" in os.environ:
user = os.environ["SMTP_USER"]
if "SMTP_PASS" in os.environ:
@@ -96,15 +101,26 @@ def reply_email(content, branch):
reply = email.message.EmailMessage()
orig = email.message_from_string(content)
- reply["To"] = ", ".join(
- email.utils.formataddr(t)
- for t in email.utils.getaddresses(
- orig.get_all("from", []) + orig.get_all("to", []) + orig.get_all("cc", [])
+ try:
+ reply["To"] = ", ".join(
+ email.utils.formataddr(t)
+ for t in email.utils.getaddresses(
+ orig.get_all("from", [])
+ + orig.get_all("to", [])
+ + orig.get_all("cc", [])
+ )
)
- )
+ except ValueError:
+ logging.warning("Failed to parse email addresses, not sending email")
+ return
reply["From"] = "linux-firmware@kernel.org"
- reply["Subject"] = "Re: {}".format(orig["Subject"])
+ try:
+ reply["Subject"] = "Re: {}".format(orig["Subject"])
+ except ValueError:
+ logging.warning("Failed to parse subject, not sending email")
+ return
+
reply["In-Reply-To"] = orig["Message-Id"]
reply["References"] = orig["Message-Id"]
reply["Thread-Topic"] = orig["Thread-Topic"]