Skip to content

Commit 661834d

Browse files
committed
Merge pull request #1261 from laanwj/2012_05_escapecsv
Properly escape strings when exporting CSV
2 parents 9dfa3c3 + 875f71d commit 661834d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/qt/csvmodelwriter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ void CSVModelWriter::addColumn(const QString &title, int column, int role)
2727

2828
static void writeValue(QTextStream &f, const QString &value)
2929
{
30-
// TODO: quoting if " or \n in string
31-
f << "\"" << value << "\"";
30+
QString escaped = value;
31+
escaped.replace('"', "\"\"");
32+
f << "\"" << escaped << "\"";
3233
}
3334

3435
static void writeSep(QTextStream &f)

0 commit comments

Comments
 (0)