diff options
author | Magnus Hagander | 2022-04-01 14:00:50 +0000 |
---|---|---|
committer | Magnus Hagander | 2022-04-01 14:00:50 +0000 |
commit | 55f23a7b991d5ce3661e8685c4bd667efe09b10d (patch) | |
tree | cf17ba278187907032393086db35046193f9076c /loader/lib/parser.py | |
parent | 6b9fedb2c69ea634b9f04a7fdd138783f8735289 (diff) |
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
Diffstat (limited to 'loader/lib/parser.py')
-rw-r--r-- | loader/lib/parser.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/loader/lib/parser.py b/loader/lib/parser.py index 171f197..8b9c87a 100644 --- a/loader/lib/parser.py +++ b/loader/lib/parser.py @@ -384,15 +384,17 @@ class ArchivesParser(object): # However, this will also *always* catch the MIME part added # by majordomo with the footer. So if that one is present, # we need to explicitly exclude it again. + # For this reason, we need it in both bytes and string format, so we can apply the regexp try: b = container.get_payload(decode=True) + s = self.get_payload_as_unicode(container) except AssertionError: # Badly encoded data can throw an exception here, where the python # libraries fail to handle it and enters a cannot-happen path. # In which case we just ignore this attachment. return - if isinstance(b, str) and not self._re_footer.match(b): + if isinstance(b, bytes) and isinstance(s, str) and not self._re_footer.match(s): # We know there is no name for this one self.attachments.append((None, container.get_content_type(), b)) return |