diff options
author | drh <> | 2021-11-18 13:25:31 +0000 |
---|---|---|
committer | drh <> | 2021-11-18 13:25:31 +0000 |
commit | e41d30ffdd4ac37d55089c0eecba5239e7fa3cc8 (patch) | |
tree | 7b2f3f1681351322dbbf215d17cb6b678afc95fc /src | |
parent | 488b55856e794bd2f267781474cbaade9e523700 (diff) | |
download | sqlite-e41d30ffdd4ac37d55089c0eecba5239e7fa3cc8.tar.gz sqlite-e41d30ffdd4ac37d55089c0eecba5239e7fa3cc8.zip |
Fix an obscure problem associated with quoting of CSV output in the CLI.
FossilOrigin-Name: 38a9b660214c06aa6650c6bb11a429a8c74c09f1e0e5c18d691e36de4af7af71
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c.in | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/shell.c.in b/src/shell.c.in index f136103b3..672c80a25 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1764,10 +1764,12 @@ static void output_csv(ShellState *p, const char *z, int bSep){ }else{ int i; int nSep = strlen30(p->colSeparator); - for(i=0; z[i]; i++){ + int n = strlen30(z); + for(i=0; i<n; i++){ if( needCsvQuote[((unsigned char*)z)[i]] - || (z[i]==p->colSeparator[0] && - (nSep==1 || memcmp(z, p->colSeparator, nSep)==0)) ){ + || (z[i]==p->colSeparator[0] && + (nSep==1 || (i+nSep<n && memcmp(z+i, p->colSeparator, nSep)==0))) + ){ i = 0; break; } |