From 5ad4ad3be69d862c25a4b56174d26768bec8122d Mon Sep 17 00:00:00 2001 From: Elias Meire Date: Thu, 21 Sep 2023 13:29:13 +0200 Subject: [PATCH] Handle filename* with quotes in Content-Disposition header --- packages/core/src/NodeExecuteFunctions.ts | 2 +- packages/core/test/NodeExecuteFunctions.test.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index f033400fcdae8..56360c6022b49 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -649,7 +649,7 @@ function parseFileName(filename?: string): string | undefined { // https://datatracker.ietf.org/doc/html/rfc5987 function parseFileNameStar(filename?: string): string | undefined { - const [_encoding, _locale, content] = filename?.split("'") ?? []; + const [_encoding, _locale, content] = parseFileName(filename)?.split("'") ?? []; return content; } diff --git a/packages/core/test/NodeExecuteFunctions.test.ts b/packages/core/test/NodeExecuteFunctions.test.ts index 16a77c8470721..b0ef257a89562 100644 --- a/packages/core/test/NodeExecuteFunctions.test.ts +++ b/packages/core/test/NodeExecuteFunctions.test.ts @@ -174,6 +174,21 @@ describe('NodeExecuteFunctions', () => { }); }); + it('parses valid content-disposition header with filename* (quoted)', () => { + const message = mock({ + headers: { + 'content-type': undefined, + 'content-disposition': ' attachment;filename*="utf-8\' \'test-unsplash.jpg"', + }, + }); + parseIncomingMessage(message); + + expect(message.contentDisposition).toEqual({ + filename: 'test-unsplash.jpg', + type: 'attachment', + }); + }); + it('parses valid content-disposition header with filename and trailing ";"', () => { const message = mock({ headers: {