Skip to content

Commit 0782ee0

Browse files
Handle missing 'to' field in process_response_email. Relates to ietf-tools#3357. Commit ready for merge.
- Legacy-Id: 19312
1 parent 54a524b commit 0782ee0

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

ietf/ipr/mail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ def process_response_email(msg):
175175
IprEvent. Create a Message object for the incoming message and associate it to
176176
the original message via new IprEvent"""
177177
message = email.message_from_string(force_str(msg))
178-
to = message.get('To')
179-
178+
to = message.get('To', '')
179+
180180
# exit if this isn't a response we're interested in (with plus addressing)
181181
local,domain = get_base_ipr_request_address().split('@')
182182
if not re.match(r'^{}\+[a-zA-Z0-9_\-]{}@{}'.format(local,'{16}',domain),to):

ietf/ipr/tests.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -632,16 +632,26 @@ def test_process_response_email(self):
632632
self.assertEqual(len(outbox), 1)
633633
self.assertTrue('joe@test.com' in outbox[0]['To'])
634634

635-
# test process response uninteresting message
635+
# test process response uninteresting messages
636636
addrs = gather_address_lists('ipr_disclosure_submitted').as_strings()
637-
message_string = """To: {}
638-
Cc: {}
639-
From: joe@test.com
640-
Date: {}
641-
Subject: test
642-
""".format(addrs.to, addrs.cc, datetime.datetime.now().ctime())
643-
result = process_response_email(message_string)
644-
self.assertIsNone(result)
637+
uninteresting_message_strings = [
638+
("To: {to}\nCc: {cc}\nFrom: joe@test.com\nDate: {date}\nSubject: test\n"),
639+
("Cc: {cc}\nFrom: joe@test.com\nDate: {date}\nSubject: test\n"), # no To
640+
("To: {to}\nFrom: joe@test.com\nDate: {date}\nSubject: test\n"), # no Cc
641+
("From: joe@test.com\nDate: {date}\nSubject: test\n"), # no To or Cc
642+
("Cc: {cc}\nDate: {date}\nSubject: test\n"), # no To
643+
("To: {to}\nDate: {date}\nSubject: test\n"), # no Cc
644+
("Date: {date}\nSubject: test\n"), # no To or Cc
645+
]
646+
for message_string in uninteresting_message_strings:
647+
result = process_response_email(
648+
message_string.format(
649+
to=addrs.to,
650+
cc=addrs.cc,
651+
date=datetime.datetime.now().ctime()
652+
)
653+
)
654+
self.assertIsNone(result)
645655

646656
# test process response
647657
message_string = """To: {}

0 commit comments

Comments
 (0)