In the output of the ".dump" command in the CLI, quote newline and

carriage-return characters using the char() function, so that they do not
get eaten by end-of-line processing logic in the OS or in other command-line
utilities and/or libraries.

FossilOrigin-Name: 68f6dc7af1013f296a11db14c007cc13cc3fe56832848bfed835ed8f74dcc676
This commit is contained in:
drh 2017-03-13 18:24:06 +00:00
commit d3bb79bd0f
3 changed files with 44 additions and 23 deletions

View File

@ -1,5 +1,5 @@
C Fix\sthe\ssqlite3TreeViewSelect()\sroutine\sso\sthat\sit\sworks\swith\sa\snull\spointer\nto\sthe\sSelect\sobject.
D 2017-03-13T17:37:13.752
C In\sthe\soutput\sof\sthe\s".dump"\scommand\sin\sthe\sCLI,\squote\snewline\sand\ncarriage-return\scharacters\susing\sthe\schar()\sfunction,\sso\sthat\sthey\sdo\snot\nget\seaten\sby\send-of-line\sprocessing\slogic\sin\sthe\sOS\sor\sin\sother\scommand-line\nutilities\sand/or\slibraries.
D 2017-03-13T18:24:06.748
F Makefile.in 2dae2a56457c2885425a480e1053de8096aff924
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 9020fa41eb91f657ae0cc44145d0a2f3af520860
@ -399,7 +399,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
F src/resolve.c 3e518b962d932a997fae373366880fc028c75706
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
F src/select.c 2496d0cc6368dabe7ad2e4c7f5ed3ad9aa3b4d11cd90f33fa1d1ef72493f43aa
F src/shell.c df29706f8b19e3b6f695b4f64d6c6963348ca8a4
F src/shell.c 353f3cebb938099577494326e2853010512e0625
F src/sqlite.h.in 4d0c08f8640c586564a7032b259c5f69bf397850
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae
@ -1563,7 +1563,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P c6dda3f752c184f441624c9993e77d5031063d79a0e177b6e25a9886514a742e
R 21d5fb07d70376e4a3754546b17385a3
P 9034cf7efc603864f51e931c7dc4fbbc2d01904e951e78c88d4d80f9936250e8 8b2954dd8376e2de985cf5dedeb6eec32c430505
R 73c5fbe608fb0e20ee39173a6198ea04
T +closed 8b2954dd8376e2de985cf5dedeb6eec32c430505
U drh
Z aeef669a336ea6338a3e27ef9df24400
Z 5e4a79f0eabba6013ee57f9716ad3797

View File

@ -1 +1 @@
9034cf7efc603864f51e931c7dc4fbbc2d01904e951e78c88d4d80f9936250e8
68f6dc7af1013f296a11db14c007cc13cc3fe56832848bfed835ed8f74dcc676

View File

@ -1490,32 +1490,52 @@ static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){
/*
** Output the given string as a quoted string using SQL quoting conventions.
**
** The "\n" and "\r" characters are converted to char(10) and char(13)
** to prevent them from being transformed by end-of-line translators.
*/
static void output_quoted_string(FILE *out, const char *z){
int i;
int nSingle = 0;
char c;
setBinaryMode(out, 1);
for(i=0; z[i]; i++){
if( z[i]=='\'' ) nSingle++;
}
if( nSingle==0 ){
for(i=0; (c = z[i])!=0 && c!='\'' && c!='\n' && c!='\r'; i++){}
if( c==0 ){
utf8_printf(out,"'%s'",z);
}else{
raw_printf(out,"'");
int inQuote = 0;
int bStarted = 0;
while( *z ){
for(i=0; z[i] && z[i]!='\''; i++){}
if( i==0 ){
raw_printf(out,"''");
z++;
}else if( z[i]=='\'' ){
utf8_printf(out,"%.*s''",i,z);
z += i+1;
}else{
utf8_printf(out,"%s",z);
for(i=0; (c = z[i])!=0 && c!='\n' && c!='\r' && c!='\''; i++){}
if( c=='\'' ) i++;
if( i ){
if( !inQuote ){
if( bStarted ) raw_printf(out, "||");
raw_printf(out, "'");
inQuote = 1;
}
utf8_printf(out, "%.*s", i, z);
z += i;
bStarted = 1;
}
if( c=='\'' ){
raw_printf(out, "'");
continue;
}
if( inQuote ){
raw_printf(out, "'");
inQuote = 0;
}
if( c==0 ){
break;
}
for(i=0; (c = z[i])=='\r' || c=='\n'; i++){
if( bStarted ) raw_printf(out, "||");
raw_printf(out, "char(%d)", c);
bStarted = 1;
}
z += i;
}
raw_printf(out,"'");
if( inQuote ) raw_printf(out, "'");
}
setTextMode(out, 1);
}