add file check for Unstructured

This commit is contained in:
Henry 2025-11-13 00:24:25 +00:00
parent e6ff9b259b
commit e3ee0b4f88
1 changed files with 2 additions and 2 deletions

View File

@ -10,7 +10,7 @@ import {
import { getCredentialData, getCredentialParam, handleEscapeCharacters } from '../../../src/utils'
import { getFileFromStorage, INodeOutputsValue } from '../../../src'
import { UnstructuredLoader } from './Unstructured'
import { isPathTraversal } from '../../../src/validator'
import { isPathTraversal, isUnsafeFilePath } from '../../../src/validator'
import sanitize from 'sanitize-filename'
import path from 'path'
@ -565,7 +565,7 @@ class UnstructuredFile_DocumentLoaders implements INode {
throw new Error('Invalid file path format')
}
if (isPathTraversal(filePath)) {
if (isPathTraversal(filePath) || isUnsafeFilePath(filePath)) {
throw new Error('Invalid path characters detected in filePath - path traversal not allowed')
}