Fix: Test metadata items for Unicode issues (#5707)

Test each key for unicode issues and reject ones which will fail inside DRF
This commit is contained in:
Trenton H authored and GitHub committed 2024-02-09 20:08:23 +00:00
1 parent cd3b1a221e
commit 0b1523f4e5
2 files changed
+18 -3

No files matched your search

+5
View File
@@ -69,6 +69,11 @@ class MailDocumentParser(DocumentParser):
for key, value in mail.headers.items():
value = ", ".join(i for i in value)
try:
value.encode("utf-8")
except UnicodeEncodeError as e: # pragma: no cover
self.log.debug(f"Skipping header {key}: {e}")
continue
result.append(
{