mirror of
https://github.com/nodemailer/wildduck.git
synced 2024-11-10 17:47:07 +08:00
update reuse cid for same data url
This commit is contained in:
parent
ec3317b2b6
commit
2f3c45d98e
2 changed files with 10 additions and 0 deletions
|
@ -2569,7 +2569,11 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler) => {
|
|||
|
||||
if (data.html && typeof data.html === 'string') {
|
||||
let fromAddress = (data.from && data.from.address).toString() || os.hostname();
|
||||
let cids = new Map();
|
||||
data.html = data.html.replace(/(<img\b[^>]* src\s*=[\s"']*)(data:[^"'>\s]+)/gi, (match, prefix, dataUri) => {
|
||||
if (cids.has(dataUri)) {
|
||||
return prefix + 'cid:' + cids.get(dataUri);
|
||||
}
|
||||
let cid = uuid.v4() + '-attachments@' + fromAddress.split('@').pop();
|
||||
data.attachments.push(
|
||||
processDataUrl({
|
||||
|
@ -2577,6 +2581,7 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler) => {
|
|||
cid
|
||||
})
|
||||
);
|
||||
cids.set(dataUri, cid);
|
||||
return prefix + 'cid:' + cid;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -330,7 +330,11 @@ module.exports = (db, server, messageHandler, userHandler) => {
|
|||
|
||||
if (data.html && typeof data.html === 'string') {
|
||||
let fromAddress = (data.from && data.from.address).toString() || os.hostname();
|
||||
let cids = new Map();
|
||||
data.html = data.html.replace(/(<img\b[^>]* src\s*=[\s"']*)(data:[^"'>\s]+)/gi, (match, prefix, dataUri) => {
|
||||
if (cids.has(dataUri)) {
|
||||
return prefix + 'cid:' + cids.get(dataUri);
|
||||
}
|
||||
let cid = uuid.v4() + '-attachments@' + fromAddress.split('@').pop();
|
||||
data.attachments.push(
|
||||
processDataUrl({
|
||||
|
@ -338,6 +342,7 @@ module.exports = (db, server, messageHandler, userHandler) => {
|
|||
cid
|
||||
})
|
||||
);
|
||||
cids.set(dataUri, cid);
|
||||
return prefix + 'cid:' + cid;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue