@@ -4,15 +4,11 @@ import {
44 UnstructuredLoaderOptions ,
55 UnstructuredLoaderStrategy ,
66 SkipInferTableTypes ,
7- HiResModelName ,
8- UnstructuredLoader as LCUnstructuredLoader
7+ HiResModelName
98} from '@langchain/community/document_loaders/fs/unstructured'
109import { getCredentialData , getCredentialParam , handleEscapeCharacters } from '../../../src/utils'
1110import { getFileFromStorage , INodeOutputsValue } from '../../../src'
1211import { UnstructuredLoader } from './Unstructured'
13- import { isPathTraversal , isUnsafeFilePath } from '../../../src/validator'
14- import sanitize from 'sanitize-filename'
15- import path from 'path'
1612
1713class UnstructuredFile_DocumentLoaders implements INode {
1814 label : string
@@ -44,17 +40,6 @@ class UnstructuredFile_DocumentLoaders implements INode {
4440 optional : true
4541 }
4642 this . inputs = [
47- /** Deprecated
48- {
49- label: 'File Path',
50- name: 'filePath',
51- type: 'string',
52- placeholder: '',
53- optional: true,
54- warning:
55- 'Use the File Upload instead of File path. If file is uploaded, this path is ignored. Path will be deprecated in future releases.'
56- },
57- */
5843 {
5944 label : 'Files Upload' ,
6045 name : 'fileObject' ,
@@ -455,7 +440,6 @@ class UnstructuredFile_DocumentLoaders implements INode {
455440 }
456441
457442 async init ( nodeData : INodeData , _ : string , options : ICommonObject ) : Promise < any > {
458- const filePath = nodeData . inputs ?. filePath as string
459443 const unstructuredAPIUrl = nodeData . inputs ?. unstructuredAPIUrl as string
460444 const strategy = nodeData . inputs ?. strategy as UnstructuredLoaderStrategy
461445 const encoding = nodeData . inputs ?. encoding as string
@@ -560,37 +544,8 @@ class UnstructuredFile_DocumentLoaders implements INode {
560544 docs . push ( ...loaderDocs )
561545 }
562546 }
563- } else if ( filePath ) {
564- if ( ! filePath || typeof filePath !== 'string' ) {
565- throw new Error ( 'Invalid file path format' )
566- }
567-
568- if ( isPathTraversal ( filePath ) || isUnsafeFilePath ( filePath ) ) {
569- throw new Error ( 'Invalid path characters detected in filePath - path traversal not allowed' )
570- }
571-
572- const parsedPath = path . parse ( filePath )
573- const sanitizedFilename = sanitize ( parsedPath . base )
574-
575- if ( ! sanitizedFilename || sanitizedFilename . trim ( ) === '' ) {
576- throw new Error ( 'Invalid filename after sanitization' )
577- }
578-
579- const sanitizedFilePath = path . join ( parsedPath . dir , sanitizedFilename )
580-
581- if ( ! path . isAbsolute ( sanitizedFilePath ) ) {
582- throw new Error ( 'File path must be absolute' )
583- }
584-
585- if ( sanitizedFilePath . includes ( '..' ) ) {
586- throw new Error ( 'Invalid file path - directory traversal not allowed' )
587- }
588-
589- const loader = new LCUnstructuredLoader ( sanitizedFilePath , obj )
590- const loaderDocs = await loader . load ( )
591- docs . push ( ...loaderDocs )
592547 } else {
593- throw new Error ( 'File path or File upload is required' )
548+ throw new Error ( 'File upload is required' )
594549 }
595550
596551 if ( metadata ) {
0 commit comments