From 684091aa015187c89d3feb2ee8fc050e5e86a309 Mon Sep 17 00:00:00 2001 From: "H. Tsubota" Date: Tue, 15 Oct 2024 00:52:38 +0900 Subject: [PATCH] =?UTF-8?q?Change=20to=20enclose=20field=20values=20?= =?UTF-8?q?=E2=80=8B=E2=80=8Bwith=20quotation=20character=20in=20exported?= =?UTF-8?q?=20CSV=20file=20if=20they=20contain=20delimiters=20in=20Spreads?= =?UTF-8?q?heet=20workbench=20(#17140)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Change to enclose field values ​​with quotation character in exported CSV file if they contain delimiters * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/Mod/Spreadsheet/App/Sheet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mod/Spreadsheet/App/Sheet.cpp b/src/Mod/Spreadsheet/App/Sheet.cpp index 241bdf30e9..589b0d90a0 100644 --- a/src/Mod/Spreadsheet/App/Sheet.cpp +++ b/src/Mod/Spreadsheet/App/Sheet.cpp @@ -342,7 +342,8 @@ bool Sheet::exportToFile(const std::string& filename, std::string str = field.str(); - if (quoteChar && str.find(quoteChar) != std::string::npos) { + if (quoteChar + && str.find_first_of(std::string(quoteChar, delimiter)) != std::string::npos) { writeEscaped(str, quoteChar, escapeChar, file); } else {