Skip to content

Commit 8ae0477

Browse files
committed
Importer: limit list of acceptable files to IMPORTABLE_TABLE_EXTENSIONS
This should reduce the possibility that our users will attempt to import the wrong kind of file.
1 parent d63dd28 commit 8ae0477

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

app/client/components/Importer.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {makeTestId} from 'app/client/lib/domUtils';
1111
import {FocusLayer} from 'app/client/lib/FocusLayer';
1212
import {ImportSourceElement} from 'app/client/lib/ImportSourceElement';
1313
import {makeT} from 'app/client/lib/localization';
14-
import {fetchURL, isDriveUrl, selectFiles, uploadFiles} from 'app/client/lib/uploads';
14+
import {EXTENSIONS_IMPORTABLE_WITHIN_DOC, fetchURL, isDriveUrl, selectFiles, uploadFiles} from 'app/client/lib/uploads';
1515
import {reportError} from 'app/client/models/AppModel';
1616
import {ColumnRec, ViewFieldRec, ViewSectionRec} from 'app/client/models/DocModel';
1717
import {SortedRowSet} from 'app/client/models/rowset';
@@ -202,7 +202,10 @@ export async function importFromFile(gristDoc: GristDoc, createPreview: CreatePr
202202
let uploadResult: UploadResult|null = null;
203203
// Use the built-in file picker. On electron, it uses the native file selector (without
204204
// actually uploading anything), which is why this requires a slightly different flow.
205-
const files: File[] = await openFilePicker({multiple: true});
205+
const files: File[] = await openFilePicker({
206+
multiple: true,
207+
accept: EXTENSIONS_IMPORTABLE_WITHIN_DOC.join(","),
208+
});
206209
// Important to fork first before trying to import, so we end up uploading to a
207210
// consistent doc worker.
208211
await gristDoc.forkIfNeeded();

0 commit comments

Comments
 (0)