mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
fix(core): Handle filename* with quotes in Content-Disposition header (#7229)
Github issue / Community forum post (link here to close automatically):
This commit is contained in:
parent
2af967cf88
commit
67b985fe89
|
@ -649,7 +649,7 @@ function parseFileName(filename?: string): string | undefined {
|
||||||
|
|
||||||
// https://datatracker.ietf.org/doc/html/rfc5987
|
// https://datatracker.ietf.org/doc/html/rfc5987
|
||||||
function parseFileNameStar(filename?: string): string | undefined {
|
function parseFileNameStar(filename?: string): string | undefined {
|
||||||
const [_encoding, _locale, content] = filename?.split("'") ?? [];
|
const [_encoding, _locale, content] = parseFileName(filename)?.split("'") ?? [];
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,6 +174,21 @@ describe('NodeExecuteFunctions', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('parses valid content-disposition header with filename* (quoted)', () => {
|
||||||
|
const message = mock<IncomingMessage>({
|
||||||
|
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 ";"', () => {
|
it('parses valid content-disposition header with filename and trailing ";"', () => {
|
||||||
const message = mock<IncomingMessage>({
|
const message = mock<IncomingMessage>({
|
||||||
headers: {
|
headers: {
|
||||||
|
|
Loading…
Reference in a new issue