Properly escape " in strings when exporting CSV

This commit is contained in:
Wladimir J. van der Laan
2012-05-11 20:17:09 +02:00
committed by Luke Dashjr
parent 7515f00aa3
commit dc15d56b2d

View File

@@ -27,8 +27,9 @@ void CSVModelWriter::addColumn(const QString &title, int column, int role)
static void writeValue(QTextStream &f, const QString &value)
{
// TODO: quoting if " or \n in string
f << "\"" << value << "\"";
QString escaped = value;
escaped.replace('"', "\"\"");
f << "\"" << escaped << "\"";
}
static void writeSep(QTextStream &f)