You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Attachment filenames with RFC 2047 encoded-words or invalid path characters cause extraction crash #4
Extraction crashes with [Errno 2] No such file or directory when an attachment filename contains RFC 2047 encoded-words or characters invalid for filesystem paths.
Evidence
ERROR attachments 860B24CB-FEF5-4651-9B07-388D74C1D77C.olk15MsgAttachment [Errno 2] No such file or directory: '/Users/thomasmaerz/olk15-export/output_fresh/attachments/860B24CB-FEF5-4651-9B07-388D74C1D77C/ =?UTF-8?B?MV9sZWFzZV/np5/os4PlkIjntIQ=?=.1.pdf'
The filename has two problems:
RFC 2047 encoded-word not decoded — =?UTF-8?B?MV9sZWFzZV/np5/os4PlkIjntIQ=?= is a base64-encoded UTF-8 string (decodes to Chinese characters) that should be decoded before writing to disk
Leading space — the filename starts with a space character, which can cause path resolution issues on some filesystems
Root Cause
parsers/attachment.py:58-64 extracts the filename from MIME headers as a raw string without:
This issue has been resolved with the following changes:
Root Cause
The attachment parser (parsers/attachment.py) extracted filenames from MIME headers as raw strings without decoding RFC 2047 encoded-words or RFC 5987 percent-encoded filenames. The raw filename was then passed directly to writer.py which wrote to disk without sanitization.
Changes Made
Added _decode_filename() function in parsers/attachment.py that:
Decodes RFC 2047 base64 and quoted-printable encoded-words
Decodes RFC 5987 percent-encoded filenames
Strips leading/trailing whitespace and surrounding quotes
Added _sanitize_filename() function in writer.py that:
Normalizes Unicode with NFC
Replaces path separators and invalid filesystem characters
Truncates to 200 chars preserving extension
Handles filename collisions
Wired both functions into the attachment parsing and writing pipeline
Verification
All 54 tests pass
The problematic attachment (860B24CB-FEF5-4651-9B07-388D74C1D77C) now extracts successfully with a decoded Chinese filename
Activity
thomasmaerz commentedon Apr 7, 2026
Fix Applied
This issue has been resolved with the following changes:
Root Cause
The attachment parser (parsers/attachment.py) extracted filenames from MIME headers as raw strings without decoding RFC 2047 encoded-words or RFC 5987 percent-encoded filenames. The raw filename was then passed directly to writer.py which wrote to disk without sanitization.
Changes Made
Added _decode_filename() function in parsers/attachment.py that:
Added _sanitize_filename() function in writer.py that:
Wired both functions into the attachment parsing and writing pipeline
Verification