[PATCH patchbot] patchbot: do not crash for malicious mails without message-id
Jun Wu
quark at fb.com
Thu Nov 17 03:16:43 UTC 2016
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1479352538 0
# Thu Nov 17 03:15:38 2016 +0000
# Node ID 7ecfbdf2460df04c1c263875a12403d3cfe3134a
# Parent 9036c3d03d301378e67d4516937ea9c6672c3c67
patchbot: do not crash for malicious mails without message-id
Sometimes due to power failure, the on-disk files could get truncated and
lose message-id. Currently patchbot would raise "KeyError: message-id" but
it does not print clues about which mail is corrupted.
This patch makes it print which mail does not contain message-id and just
ignore them.
diff --git a/index.py b/index.py
--- a/index.py
+++ b/index.py
@@ -51,4 +51,7 @@ def index_mailbox(session, mb):
if key not in all_keys:
mail = mb[key]
+ if 'message-id' not in mail:
+ sys.stderr.write('%s: ignored - no message-id\n' % key)
+ continue
if session.query(models.Message).filter(models.Message.id.is_(
mail['message-id'])).count() > 0:
More information about the Mercurial-devel
mailing list