Fixed issues with NOT

This commit is contained in:
Andris Reinman 2017-04-01 22:51:29 +03:00
parent bed2cacb4a
commit 47b3e54b13

59
imap.js
View file

@ -1277,22 +1277,23 @@ server.onSearch = function (path, options, session, callback) {
case 'header': case 'header':
{ {
// FIXME: this does not match unicode symbols for whatever reason
let regex = Buffer.from(term.value, 'binary').toString().replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
let entry = term.value ? { let entry = term.value ? {
'headers.key': term.header, 'headers.key': term.header,
'headers.value': { 'headers.value': !ne ? {
// FIXME: this does not match unicode symbols for whatever reason regex
$regex: Buffer.from(term.value, 'binary').toString().replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') } : {
$not: {
regex
}
} }
} : { } : {
'headers.key': term.header 'headers.key': !ne ? term.header : {
$ne: term.header
}
}; };
if (!ne) { parent.push(entry);
parent.push(entry);
} else {
parent.push({
$not: entry
});
}
} }
break; break;
@ -1323,16 +1324,12 @@ server.onSearch = function (path, options, session, callback) {
}; };
entry = { entry = {
internaldate: entry internaldate: !ne ? entry : {
$not: entry
}
}; };
if (!ne) { parent.push(entry);
parent.push(entry);
} else {
parent.push({
$not: entry
});
}
} }
break; break;
@ -1363,16 +1360,12 @@ server.onSearch = function (path, options, session, callback) {
}; };
entry = { entry = {
headerdate: entry headerdate: !ne ? entry : {
$not: entry
}
}; };
if (!ne) { parent.push(entry);
parent.push(entry);
} else {
parent.push({
$not: entry
});
}
} }
break; break;
@ -1400,16 +1393,12 @@ server.onSearch = function (path, options, session, callback) {
}; };
entry = { entry = {
size: entry size: !ne ? entry : {
$not: entry
}
}; };
if (!ne) { parent.push(entry);
parent.push(entry);
} else {
parent.push({
$not: entry
});
}
} }
break; break;
} }