csvstorage: add quotes on export if newline is found
@@ -632,8 +632,15 @@ static int csvWrite (KeySet * returned, Key * parentKey, Key * colAsParent, char
while ((tmp = ksNext (headerKs)) != NULL)
{
++colCounter;
+ if ((strchr (keyName (tmp), '\n') != NULL) && (keyName (tmp)[0] != '"'))
+ {
+ fprintf (fp, ";\"%s\"", keyName (tmp) + strlen (keyName (cur)) + 1);
+ }
+ else
+ {
fprintf (fp, ";%s", keyName (tmp) + strlen (keyName (cur)) + 1);
}
+ }
fprintf (fp, "\n");
if (columns == 0)
{
@@ -656,6 +663,10 @@ static int csvWrite (KeySet * returned, Key * parentKey, Key * colAsParent, char
{
fprintf (fp, "\"%s\"", keyString (toWrite));
}
+ else if ((strchr (keyString (toWrite), '\n') != NULL) && (keyString (toWrite)[0] != '"'))
+ {
+ fprintf (fp, "\"%s\"", keyString (toWrite));
+ }
else
{
fprintf (fp, "%s", keyString (toWrite));
