]> git.proxmox.com Git - mirror_linux-firmware.git/commitdiff
Make email replies more resilient
authorMario Limonciello <mario.limonciello@amd.com>
Thu, 16 Nov 2023 16:52:46 +0000 (10:52 -0600)
committerMario Limonciello <mario.limonciello@amd.com>
Thu, 16 Nov 2023 16:55:13 +0000 (10:55 -0600)
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
contrib/process_linux_firmware.py

index ea108391d44d125b300f0f3df56980e8b7ef032d..8e2eb3501c824ec2133ef53c60cd4d353b972bb0 100755 (executable)
@@ -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"]