From 2cbcd79a84ca0cdc357ea62dbe81342ab960ebb5 Mon Sep 17 00:00:00 2001 From: llama <100429699+iamllama@users.noreply.github.com> Date: Thu, 6 Feb 2025 15:23:43 +0800 Subject: [PATCH] Cap preview cols to prevent stall when csv is parsed with the wrong delimiter (#3786) * cap csv import preview table at 1000 columns * add fluent message * show warning when preview table columns have been truncated * simplify fluent message ($count will almost always be a big num) * _tr -> tr --- ftl/core/importing.ftl | 6 ++++++ ts/routes/import-csv/Preview.svelte | 28 ++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/ftl/core/importing.ftl b/ftl/core/importing.ftl index bf3162809..c0bc724f3 100644 --- a/ftl/core/importing.ftl +++ b/ftl/core/importing.ftl @@ -67,6 +67,12 @@ importing-packaged-anki-deckcollection-apkg-colpkg-zip = Packaged Anki Deck/Coll importing-pauker-18-lesson-paugz = Pauker 1.8 Lesson (*.pau.gz) # the '|' character importing-pipe = Pipe +# Warning displayed when the csv import preview table is clipped (some columns were hidden) +# $count is intended to be a large number (1000 and above) +importing-preview-truncated = + { $count -> + *[other] Only the first { $count } columns are shown. If this doesn't seem right, try changing the field separator. + } importing-rows-had-num1d-fields-expected-num2d = '{ $row }' had { $found } fields, expected { $expected } importing-selected-file-was-not-in-utf8 = Selected file was not in UTF-8 format. Please see the importing section of the manual. importing-semicolon = Semicolon diff --git a/ts/routes/import-csv/Preview.svelte b/ts/routes/import-csv/Preview.svelte index c5ae37879..5f0829450 100644 --- a/ts/routes/import-csv/Preview.svelte +++ b/ts/routes/import-csv/Preview.svelte @@ -3,12 +3,34 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -->