Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 0f6d59e

Browse files
committed
Cleanup msg-id tokens before comparison
Python doesn't handle this for some reason, and doesn't seem to have any helper to do so.
1 parent 59d92b0 commit 0f6d59e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

emailthreads/threads.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@
66
from .util import *
77
from .quotes import *
88

9-
def get_message_by_id(msgs, msg_id):
10-
if msg_id is None or msg_id == "":
9+
def canonical_msg_id(msg_id):
10+
if msg_id == None:
11+
return None
12+
msg_id = str(msg_id).strip()
13+
if msg_id == "":
1114
return None
1215
# TODO: handle weird brackets stuff
16+
return msg_id
17+
18+
def get_message_by_id(msgs, msg_id):
19+
msg_id = canonical_msg_id(msg_id)
20+
if msg_id == None:
21+
return None
1322
for msg in msgs:
14-
if msg["message-id"] == msg_id:
23+
if canonical_msg_id(msg["message-id"]) == msg_id:
1524
return msg
1625
return None
1726

0 commit comments

Comments
 (0)