mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-10-27 14:37:33 +08:00
v1.0.47. Do not throw on invalid punycode or html
This commit is contained in:
parent
b56e516843
commit
b5ffa5c973
6 changed files with 36 additions and 10 deletions
|
|
@ -338,7 +338,7 @@ module.exports.filterFolders = function(folders, query) {
|
|||
// setup *
|
||||
.replace(/[*]/g, '.*')
|
||||
// setup %
|
||||
.replace(/[%]/g, '[^\/]*');
|
||||
.replace(/[%]/g, '[^/]*');
|
||||
|
||||
let regex = new RegExp('^' + query + '$', '');
|
||||
|
||||
|
|
@ -374,13 +374,13 @@ module.exports.getMessageRange = function(uidList, range, isUid) {
|
|||
return false;
|
||||
};
|
||||
|
||||
for ((i = 0), (len = uidList.length); i < len; i++) {
|
||||
for (i = 0, len = uidList.length; i < len; i++) {
|
||||
if (uidList[i] > maxUid) {
|
||||
maxUid = uidList[i];
|
||||
}
|
||||
}
|
||||
|
||||
for ((i = 0), (len = uidList.length); i < len; i++) {
|
||||
for (i = 0, len = uidList.length; i < len; i++) {
|
||||
uid = uidList[i] || 1;
|
||||
if (inRange(isUid ? uid : i + 1, rangeParts, isUid ? maxUid : totalMessages)) {
|
||||
result.push(uidList[i]);
|
||||
|
|
@ -592,7 +592,11 @@ module.exports.getQueryResponse = function(query, message, options) {
|
|||
if (!Buffer.isBuffer(val) && val.buffer) {
|
||||
val = val.buffer;
|
||||
}
|
||||
addr[3] = punycode.toASCII(val.toString());
|
||||
try {
|
||||
addr[3] = punycode.toASCII(val.toString());
|
||||
} catch (E) {
|
||||
addr[3] = val.toString();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,11 @@ function processAddress(arr, defaults) {
|
|||
}
|
||||
|
||||
if (domain) {
|
||||
domain = Buffer.from(punycode.toUnicode(domain));
|
||||
try {
|
||||
domain = Buffer.from(punycode.toUnicode(domain));
|
||||
} catch (E) {
|
||||
domain = Buffer.from(domain);
|
||||
}
|
||||
}
|
||||
|
||||
result.push([name, null, user, domain]);
|
||||
|
|
|
|||
|
|
@ -343,7 +343,12 @@ class Indexer {
|
|||
if (contentType === 'text/html') {
|
||||
htmlContent.push(content.trim());
|
||||
if (!alternative) {
|
||||
textContent.push(htmlToText.fromString(content).trim());
|
||||
try {
|
||||
let text = htmlToText.fromString(content);
|
||||
textContent.push(text.trim());
|
||||
} catch (E) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
} else {
|
||||
textContent.push(content.trim());
|
||||
|
|
|
|||
|
|
@ -49,7 +49,13 @@ function parseAddressses(headerList, withNames) {
|
|||
}
|
||||
|
||||
function normalizeDomain(domain) {
|
||||
return punycode.toASCII(domain.toLowerCase().trim());
|
||||
domain = domain.toLowerCase().trim();
|
||||
try {
|
||||
domain = punycode.toASCII(domain);
|
||||
} catch (E) {
|
||||
// ignore
|
||||
}
|
||||
return domain;
|
||||
}
|
||||
|
||||
// helper function to flatten arrays
|
||||
|
|
|
|||
|
|
@ -13,7 +13,14 @@ function normalizeAddress(address, withNames) {
|
|||
}
|
||||
let user = address.address.substr(0, address.address.lastIndexOf('@')).normalize('NFC').toLowerCase().trim();
|
||||
let domain = address.address.substr(address.address.lastIndexOf('@') + 1).toLowerCase().trim();
|
||||
let addr = user + '@' + punycode.toUnicode(domain);
|
||||
let encodedDomain = domain;
|
||||
try {
|
||||
encodedDomain = punycode.toUnicode(domain);
|
||||
} catch (E) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
let addr = user + '@' + encodedDomain;
|
||||
|
||||
if (withNames) {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "wildduck",
|
||||
"version": "1.0.46",
|
||||
"version": "1.0.47",
|
||||
"description": "IMAP server built with Node.js and MongoDB",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
"html-to-text": "^3.3.0",
|
||||
"iconv-lite": "^0.4.17",
|
||||
"joi": "^10.5.2",
|
||||
"libbase64": "^0.1.0",
|
||||
"libbase64": "^0.2.0",
|
||||
"libmime": "^3.1.0",
|
||||
"libqp": "^1.1.0",
|
||||
"mailsplit": "^4.0.2",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue