mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(editor): Sanitize HTML binary-data before rendering in the UI (#7400)
This commit is contained in:
committed by
GitHub
parent
47e8953ec9
commit
2b075bfc2d
@@ -35,7 +35,7 @@ export type IAllExecuteFunctions =
|
||||
| ITriggerFunctions
|
||||
| IWebhookFunctions;
|
||||
|
||||
export type BinaryFileType = 'text' | 'json' | 'image' | 'audio' | 'video' | 'pdf';
|
||||
export type BinaryFileType = 'text' | 'json' | 'image' | 'audio' | 'video' | 'pdf' | 'html';
|
||||
export interface IBinaryData {
|
||||
[key: string]: string | undefined;
|
||||
data: string;
|
||||
|
||||
@@ -112,6 +112,7 @@ export const sleep = async (ms: number): Promise<void> =>
|
||||
|
||||
export function fileTypeFromMimeType(mimeType: string): BinaryFileType | undefined {
|
||||
if (mimeType.startsWith('application/json')) return 'json';
|
||||
if (mimeType.startsWith('text/html')) return 'html';
|
||||
if (mimeType.startsWith('image/')) return 'image';
|
||||
if (mimeType.startsWith('audio/')) return 'audio';
|
||||
if (mimeType.startsWith('video/')) return 'video';
|
||||
|
||||
@@ -196,6 +196,10 @@ describe('fileTypeFromMimeType', () => {
|
||||
expect(fileTypeFromMimeType('application/json')).toEqual('json');
|
||||
});
|
||||
|
||||
it('should recognize html', () => {
|
||||
expect(fileTypeFromMimeType('text/html')).toEqual('html');
|
||||
});
|
||||
|
||||
it('should recognize image', () => {
|
||||
expect(fileTypeFromMimeType('image/jpeg')).toEqual('image');
|
||||
expect(fileTypeFromMimeType('image/png')).toEqual('image');
|
||||
@@ -219,7 +223,7 @@ describe('fileTypeFromMimeType', () => {
|
||||
it('should recognize text', () => {
|
||||
expect(fileTypeFromMimeType('text/plain')).toEqual('text');
|
||||
expect(fileTypeFromMimeType('text/css')).toEqual('text');
|
||||
expect(fileTypeFromMimeType('text/html')).toEqual('text');
|
||||
expect(fileTypeFromMimeType('text/html')).not.toEqual('text');
|
||||
expect(fileTypeFromMimeType('text/javascript')).toEqual('text');
|
||||
expect(fileTypeFromMimeType('application/javascript')).toEqual('text');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user