File tree Expand file tree Collapse file tree
server/src/services/chatflows Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1202,8 +1202,9 @@ export const mapMimeTypeToExt = (mimeType: string) => {
12021202 * MIME types allowed for full file upload (chatflow config).
12031203 * Server validates stored allowedUploadFileTypes against this list to prevent
12041204 * malicious clients from allowing executables or other dangerous types.
1205+ * Uses a Set for O(1) lookups and to make the unique allowed set explicit.
12051206 */
1206- export const ALLOWED_UPLOAD_MIME_TYPES : readonly string [ ] = [
1207+ export const ALLOWED_UPLOAD_MIME_TYPES : ReadonlySet < string > = new Set ( [
12071208 'text/css' ,
12081209 'text/csv' ,
12091210 'text/html' ,
@@ -1218,7 +1219,7 @@ export const ALLOWED_UPLOAD_MIME_TYPES: readonly string[] = [
12181219 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ,
12191220 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ,
12201221 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
1221- ]
1222+ ] )
12221223
12231224/**
12241225 * Returns true if the MIME type is allowed for file upload config.
@@ -1230,7 +1231,7 @@ export const isAllowedUploadMimeType = (mime: string): boolean => {
12301231 if ( ! mime || typeof mime !== 'string' ) return false
12311232 const trimmed = mime . trim ( )
12321233 if ( ! trimmed ) return false
1233- return ALLOWED_UPLOAD_MIME_TYPES . includes ( trimmed ) && mapMimeTypeToExt ( trimmed ) !== ''
1234+ return ALLOWED_UPLOAD_MIME_TYPES . has ( trimmed ) && mapMimeTypeToExt ( trimmed ) !== ''
12341235}
12351236
12361237// remove invalid markdown image pattern: 
Original file line number Diff line number Diff line change @@ -361,8 +361,10 @@ const updateChatflow = async (
361361 parsed . fullFileUpload . allowedUploadFileTypes = sanitized
362362 updateChatFlow . chatbotConfig = JSON . stringify ( parsed )
363363 }
364- } catch {
365- // If parsing fails, leave chatbotConfig unchanged
364+ } catch ( error ) {
365+ const message = getErrorMessage ( error )
366+ logger . error ( `[server]: Invalid chatbotConfig JSON in updateChatflow: ${ message } ` )
367+ throw new InternalFlowiseError ( StatusCodes . BAD_REQUEST , `Invalid chatbotConfig: ${ message } ` )
366368 }
367369 }
368370 const newDbChatflow = appServer . AppDataSource . getRepository ( ChatFlow ) . merge ( chatflow , updateChatFlow )
You can’t perform that action at this time.
0 commit comments