mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-10-06 11:57:27 +08:00
v1.17.2
This commit is contained in:
parent
d893d9239d
commit
664b3792a4
2 changed files with 42 additions and 1 deletions
|
@ -4,6 +4,8 @@ const config = require('wild-config');
|
||||||
const log = require('npmlog');
|
const log = require('npmlog');
|
||||||
const libmime = require('libmime');
|
const libmime = require('libmime');
|
||||||
const Joi = require('../joi');
|
const Joi = require('../joi');
|
||||||
|
const uuid = require('uuid');
|
||||||
|
const os = require('os');
|
||||||
const MongoPaging = require('mongo-cursor-pagination');
|
const MongoPaging = require('mongo-cursor-pagination');
|
||||||
const addressparser = require('nodemailer/lib/addressparser');
|
const addressparser = require('nodemailer/lib/addressparser');
|
||||||
const MailComposer = require('nodemailer/lib/mail-composer');
|
const MailComposer = require('nodemailer/lib/mail-composer');
|
||||||
|
@ -2436,6 +2438,20 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler) => {
|
||||||
keepBcc: true
|
keepBcc: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (data.html && typeof data.html === 'string') {
|
||||||
|
let fromAddress = (data.from && data.from.address).toString() || os.hostname();
|
||||||
|
data.html = data.html.replace(/(<img\b[^>]* src\s*=[\s"']*)(data:[^"'>\s]+)/gi, (match, prefix, dataUri) => {
|
||||||
|
let cid = uuid.v4() + '-attachments@' + fromAddress.split('@').pop();
|
||||||
|
data.attachments.push(
|
||||||
|
processDataUrl({
|
||||||
|
path: dataUri,
|
||||||
|
cid
|
||||||
|
})
|
||||||
|
);
|
||||||
|
return prefix + 'cid:' + cid;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// ensure plaintext content if html is provided
|
// ensure plaintext content if html is provided
|
||||||
if (data.html && !data.text) {
|
if (data.html && !data.text) {
|
||||||
try {
|
try {
|
||||||
|
@ -4002,3 +4018,28 @@ function parseAddresses(data) {
|
||||||
walk([].concat(data || []));
|
walk([].concat(data || []));
|
||||||
return Array.from(addresses);
|
return Array.from(addresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function processDataUrl(element) {
|
||||||
|
let parts = (element.path || element.href).match(/^data:((?:[^;]*;)*(?:[^,]*)),(.*)$/i);
|
||||||
|
if (!parts) {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
element.content = /\bbase64$/i.test(parts[1]) ? Buffer.from(parts[2], 'base64') : Buffer.from(decodeURIComponent(parts[2]));
|
||||||
|
|
||||||
|
if ('path' in element) {
|
||||||
|
element.path = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('href' in element) {
|
||||||
|
element.href = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
parts[1].split(';').forEach(item => {
|
||||||
|
if (/^\w+\/[^/]+$/i.test(item)) {
|
||||||
|
element.contentType = element.contentType || item.toLowerCase();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "wildduck",
|
"name": "wildduck",
|
||||||
"version": "1.17.1",
|
"version": "1.17.2",
|
||||||
"description": "IMAP/POP3 server built with Node.js and MongoDB",
|
"description": "IMAP/POP3 server built with Node.js and MongoDB",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
Loading…
Add table
Reference in a new issue