mailparser
mailparser copied to clipboard
For headers where a single value should be kept, it should be the first one instead of the last
See mail-parser.js at line 396:
// keep only the first value
let singleKeys = [
'message-id',
'content-id',
'from',
'sender',
'in-reply-to',
'reply-to',
'subject',
'date',
'content-disposition',
'content-type',
'content-transfer-encoding',
'priority',
'mime-version',
'content-description',
'precedence',
'errors-to',
'disposition-notification-to'
];
headers.forEach((value, key) => {
if (Array.isArray(value)) {
if (singleKeys.includes(key) && value.length) {
headers.set(key, value[value.length - 1]);
} else if (value.length === 1) {
headers.set(key, value[0]);
}
}
if (key === 'list') {
// normalize List-* headers
let listValue = {};
[].concat(value || []).forEach(val => {
Object.keys(val || {}).forEach(listKey => {
listValue[listKey] = val[listKey];
});
});
headers.set(key, listValue);
}
});
Comment says it should keep the first item, but instead we get the last one
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Well, I still think this should be fixed