From c82dc920631e82eb3ed75dfa5caea34ec407bd35 Mon Sep 17 00:00:00 2001 From: Donald Ness Date: Thu, 12 Jan 2023 09:44:07 -0600 Subject: [PATCH] Fix cases where contact headers have missing values --- extract_msg/contact.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/extract_msg/contact.py b/extract_msg/contact.py index c835af62..f694f178 100644 --- a/extract_msg/contact.py +++ b/extract_msg/contact.py @@ -689,11 +689,13 @@ def headerFormatProperties(self) -> constants.HEADER_FORMAT_TYPE: If you class should not do *any* header injection, return None from this property. """ - def strListToStr(inp : Union[str, List[str]]): + def strListToStr(inp : Union[str, None, List[str]]): """ Small internal function for things that may return a string or list. """ - if isinstance(inp, str): + if inp is None: + return None + elif isinstance(inp, str): return inp else: return ', '.join(inp) @@ -750,7 +752,7 @@ def strListToStr(inp : Union[str, List[str]]): 'Anniversary': self.weddingAnniversary.__format__('%B %d, %Y') if self.weddingAnniversaryLocal else None, 'Spouse/Partner': self.spouseName, 'Profession': self.profession, - 'Children': ', '.join(self.childrensNames), + 'Children': strListToStr(self.childrensNames), 'Hobbies': self.hobbies, 'Assistant': self.assistant, 'Web Page': self.webpageUrl,