From a9a22282d9bc2b2345f72ddcc945d618a7595a29 Mon Sep 17 00:00:00 2001 From: Roy Falk Date: Sun, 27 Oct 2024 12:17:05 +0200 Subject: [PATCH] Fix bug 865 (#897) --- engine/src/cmd/csv.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/engine/src/cmd/csv.cpp b/engine/src/cmd/csv.cpp index a537de5400..b49a3c826a 100644 --- a/engine/src/cmd/csv.cpp +++ b/engine/src/cmd/csv.cpp @@ -32,6 +32,8 @@ #include "unit_json_factory.h" #include "vs_exit.h" +#include + using std::string; std::vector readCSV(const string &s, string delim) { @@ -116,10 +118,18 @@ string writeCSV(const std::map &unit, string delim) { std::string first_line; std::string second_line; for (auto const& pair : unit) { - first_line += addQuote(pair.first, delim); + std::string pair_first = pair.first; + std::string pair_second = pair.second; + + // Replaces standard comma with turned comma (U+2E32) + // Prevents CSV corruption on load. + boost::replace_all(pair_first, ",", "⸲"); + boost::replace_all(pair_second, ",", "⸲"); + + first_line += addQuote(pair_first, delim); first_line += delim[0]; - second_line += addQuote(pair.second, delim); + second_line += addQuote(pair_second, delim); second_line += delim[0]; }