Fix mail parser

This commit is contained in:
Christian Wolf 2025-02-26 13:37:45 +01:00
parent c685ebd3e0
commit 4450a17426

View File

@ -44,13 +44,16 @@ class MailParser:
if not ct.startswith('multipart/alternative'): if not ct.startswith('multipart/alternative'):
raise Exception('Not yet implemented') raise Exception('Not yet implemented')
parser = re.compile('.*boundary="([^"]+)"') parser = re.compile(r'.*boundary=("([^"]+)"|([^ ]+))')
matcher = parser.match(ct) matcher = parser.match(ct)
if matcher is None: if matcher is None:
self._l.error('Cannot extract boundary from mail header.') self._l.error('Cannot extract boundary from mail header.')
exit(1) exit(1)
boundary = matcher.group(1) if matcher.group(2) is not None:
boundary = matcher.group(2)
elif matcher.group(3) is not None:
boundary = matcher.group(3)
return 'multipart/alternative', boundary return 'multipart/alternative', boundary