-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
enhancementNew feature or requestNew feature or request
Description
When using attachment headers that include multiple parts of encoded strings the parser fails to return the proper file names.
I think the behavior should be like in emailjs-mime-codec mimeWordsDecode function.
Here are a few unit tests for validation:
it('should return an empty string for empty input', () => {
expect(mimeWordsDecode('')).toBe('')
})
it('should return the original string if not MIME-encoded', () => {
const plain = 'simple-filename.txt'
expect(mimeWordsDecode(plain)).toBe(plain)
})
it('should decode a single Base64-encoded word', () => {
const encoded = '=?UTF-8?Q?See_on_=C3=B5hin_test?='
const decoded = mimeWordsDecode(encoded)
expect(decoded).toBe('See on õhin test')
})
it('should decode multipart Base64-encoded words into a single string', () => {
const encoded
= '=?utf-8?B?UmVwb3J0X0ZpbmFuY2lhbF9TdW1t?= =?utf-8?B?YXJ5XzIwMjVfSmFuLnBkZg==?='
const decoded = mimeWordsDecode(encoded)
expect(decoded).toBe('Report_Financial_Summary_2025_Jan.pdf')
})
it('should handle different encodings in the same header', () => {
const plain = `=?utf-8?B?anVzdCBhbiBleGFtcGxlX18=?=
=?utf-8?Q?unencoded.xlsx?=`
expect(mimeWordsDecode(plain)).toBe('just an example__unencoded.xlsx')
})Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request