Skip to content

Commit c94ee72

Browse files
committed
remove x-filename
1 parent ced0143 commit c94ee72

2 files changed

Lines changed: 3 additions & 32 deletions

File tree

lib/api/messages.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,8 +1798,6 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti
17981798

17991799
let [attachmentCharset] = getAttachmentCharset(messageData.mimeTree, attachment);
18001800
let [attachmentContentDisposition] = getAttachmentContentDisposition(messageData.mimeTree, attachment);
1801-
let [attachmentFilename] = getAttachmentFilename(messageData.mimeTree, attachment);
1802-
18031801
let headers = {
18041802
'Content-Type': attachmentData.contentType || 'application/octet-stream'
18051803
};
@@ -1808,10 +1806,6 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti
18081806
headers['Content-Disposition'] = attachmentContentDisposition;
18091807
}
18101808

1811-
if (attachmentFilename) {
1812-
headers['X-Filename'] = attachmentFilename;
1813-
}
1814-
18151809
res.writeHead(200, headers);
18161810

18171811
let decode = true;
@@ -4384,25 +4378,3 @@ function getAttachmentContentDisposition(mimeTree, attachmentId) {
43844378

43854379
return [false, false];
43864380
}
4387-
4388-
function getAttachmentFilename(mimeTree, attachmentId) {
4389-
if (mimeTree.attachmentId && mimeTree.attachmentId === attachmentId) {
4390-
let filename = mimeTree.parsedHeader['content-disposition']?.params?.filename || false;
4391-
4392-
if (filename) {
4393-
return [filename.toString().replace(/\s*\r?\n\s*/g, ' ').trim(), true];
4394-
}
4395-
4396-
return [false, true];
4397-
} else if (mimeTree.childNodes) {
4398-
let filename;
4399-
for (const childNode of Object.values(mimeTree.childNodes)) {
4400-
filename = getAttachmentFilename(childNode, attachmentId);
4401-
if (filename[1] === true) {
4402-
return filename;
4403-
}
4404-
}
4405-
}
4406-
4407-
return [false, false];
4408-
}

test/api-test.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,13 +630,12 @@ describe('API tests', function () {
630630
.expect(200);
631631

632632
expect(downloadResponse.headers['content-disposition']).to.match(/^inline\b/i);
633-
expect(downloadResponse.headers['x-filename']).to.equal('inline-test.txt');
634633
expect(downloadResponse.text).to.equal('test');
635634
});
636635

637-
it('should GET /users/:user/mailboxes/:mailbox/messages/:message/attachments/:attachment expect utf8 filename header', async () => {
636+
it('should GET /users/:user/mailboxes/:mailbox/messages/:message/attachments/:attachment expect utf8 filename in content disposition', async () => {
638637
const utf8Filename = 'täst-Ā.txt';
639-
const expectedHeaderFilename = '=?UTF-8?Q?t=C3=A4st-=C4=80.txt?=';
638+
const expectedHeaderFilename = "filename*0*=utf-8''t%C3%A4st-%C4%80.txt";
640639
const message = {
641640
from: {
642641
name: 'test tester',
@@ -668,7 +667,7 @@ describe('API tests', function () {
668667
.expect(200);
669668

670669
expect(downloadResponse.headers['content-disposition']).to.match(/^inline\b/i);
671-
expect(downloadResponse.headers['x-filename']).to.equal(expectedHeaderFilename);
670+
expect(downloadResponse.headers['content-disposition']).to.include(expectedHeaderFilename);
672671
expect(downloadResponse.text).to.equal('test');
673672
});
674673

0 commit comments

Comments
 (0)