Skip to content

Commit 55f23a7

Browse files
committed
Fix bytes/str handling of secondary text parts in messages
This was broken in the python 2->3 migration, but is apparently an uncommon enough case that it wasn't properly spotted until now. Reported and pointers in the right direction from Andres Freund
1 parent 6b9fedb commit 55f23a7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

loader/lib/parser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,17 @@ def recursive_get_attachments(self, container):
384384
# However, this will also *always* catch the MIME part added
385385
# by majordomo with the footer. So if that one is present,
386386
# we need to explicitly exclude it again.
387+
# For this reason, we need it in both bytes and string format, so we can apply the regexp
387388
try:
388389
b = container.get_payload(decode=True)
390+
s = self.get_payload_as_unicode(container)
389391
except AssertionError:
390392
# Badly encoded data can throw an exception here, where the python
391393
# libraries fail to handle it and enters a cannot-happen path.
392394
# In which case we just ignore this attachment.
393395
return
394396

395-
if isinstance(b, str) and not self._re_footer.match(b):
397+
if isinstance(b, bytes) and isinstance(s, str) and not self._re_footer.match(s):
396398
# We know there is no name for this one
397399
self.attachments.append((None, container.get_content_type(), b))
398400
return

0 commit comments

Comments
 (0)