ensure that in-reply-to and message-id headers are stored as single strings, not arrays

This commit is contained in:
Andris Reinman 2021-10-12 23:18:17 +03:00
parent bb59b538e6
commit 803e21a9a8
No known key found for this signature in database
GPG key ID: DC6C83F4D584D364
2 changed files with 16 additions and 1 deletions

View file

@ -559,6 +559,12 @@ module.exports.getQueryResponse = function (query, message, options) {
case 'envelope':
if (message.envelope) {
value = message.envelope;
// cast invalidly stored In-Reply-To (8) and Message-ID (9) to strings
for (let index of [9, 10]) {
if (value[index] && Array.isArray(value[index])) {
value[index] = value[index].pop() || null;
}
}
} else {
if (!mimeTree) {
mimeTree = indexer.parseMimeTree(message.raw);

View file

@ -217,7 +217,16 @@ class MIMEParser {
});
// ensure single value for selected fields
['content-transfer-encoding', 'content-id', 'content-description', 'content-language', 'content-md5', 'content-location'].forEach(key => {
[
'in-reply-to',
'message-id',
'content-transfer-encoding',
'content-id',
'content-description',
'content-language',
'content-md5',
'content-location'
].forEach(key => {
if (Array.isArray(this._node.parsedHeader[key])) {
this._node.parsedHeader[key] = this._node.parsedHeader[key].pop();
}