Improved handling of backslash escapes on double-quoted arguments to

dot-commands in the command-line shell.

FossilOrigin-Name: 656a1fe5dd670e6ce7173ed3ce3392c0151641a0
This commit is contained in:
drh 2013-06-27 13:26:55 +00:00
parent 340f582ec3
commit 4c56b99f2e
4 changed files with 24 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C The\sundocumented\sand\sunsupported\s".selftest"\scommand\sin\sthe\scommand-line\nshell\sutility\sis\snow\sonly\savailable\sif\scompiled\swith\sSQLITE_DEBUG.\s\sAlso\nfix\sa\swindows\scompiler\swarning\sin\sthat\scommand.
D 2013-06-27T13:01:21.431
C Improved\shandling\sof\sbackslash\sescapes\son\sdouble-quoted\sarguments\sto\ndot-commands\sin\sthe\scommand-line\sshell.
D 2013-06-27T13:26:55.828
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -217,7 +217,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
F src/resolve.c 89f9003e8316ee3a172795459efc2a0274e1d5a8
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
F src/select.c 91b62654caf8dfe292fb8882715e575d34ad3874
F src/shell.c fab2f606a82871c9f0862b79db7305e230a1bb97
F src/shell.c 3b8fff51ad65fb932b0b29a2a33c1991a4c56a9b
F src/sqlite.h.in 9e8d57aa4d2fdc181dc25e9aa295f5ecec7e184a
F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
F src/sqlite3ext.h d936f797812c28b81b26ed18345baf8db28a21a5
@ -773,7 +773,7 @@ F test/shared9.test 5f2a8f79b4d6c7d107a01ffa1ed05ae7e6333e21
F test/sharedA.test 0cdf1a76dfa00e6beee66af5b534b1e8df2720f5
F test/shared_err.test 0079c05c97d88cfa03989b7c20a8b266983087aa
F test/sharedlock.test 927a4b6da11978c82b857dbdb20a932aad732123
F test/shell1.test 338f51e6ff543720c609178bda81c2606df8df8d
F test/shell1.test 928547277d385038c696428e9d791cbbad098974
F test/shell2.test 037d6ad16e873354195d30bb2dc4b5321788154a
F test/shell3.test 9196c42772d575685e722c92b4b39053c6ebba59
F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9
@ -1098,7 +1098,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
P 361c22969aa75340ed696e00e3dc5d17d5493bee
R 52837f7d4da2db768acfe7016d71fba7
P e88fd5b22198edfc6f91390194bdde07ca06ba35
R e0ea5c577e99c4c9e7b89055ec3f7b29
U drh
Z f3345aa28aafc2e60fbdaabb70077fb7
Z e3dc96e0e57dde00a2c7ad221cef5689

View File

@ -1 +1 @@
e88fd5b22198edfc6f91390194bdde07ca06ba35
656a1fe5dd670e6ce7173ed3ce3392c0151641a0

View File

@ -1492,6 +1492,7 @@ static void open_db(struct callback_data *p){
** \t -> tab
** \n -> newline
** \r -> carriage return
** \" -> "
** \NNN -> ascii character NNN in octal
** \\ -> backslash
*/
@ -1507,6 +1508,8 @@ static void resolve_backslashes(char *z){
c = '\t';
}else if( c=='r' ){
c = '\r';
}else if( c=='\\' ){
c = '\\';
}else if( c>='0' && c<='7' ){
c -= '0';
if( z[i+1]>='0' && z[i+1]<='7' ){
@ -1772,7 +1775,10 @@ static int do_meta_command(char *zLine, struct callback_data *p){
if( zLine[i]=='\'' || zLine[i]=='"' ){
int delim = zLine[i++];
azArg[nArg++] = &zLine[i];
while( zLine[i] && zLine[i]!=delim ){ i++; }
while( zLine[i] && zLine[i]!=delim ){
if( zLine[i]=='\\' && delim=='"' && zLine[i+1]!=0 ) i++;
i++;
}
if( zLine[i]==delim ){
zLine[i++] = 0;
}

View File

@ -710,6 +710,15 @@ do_test shell1-3-29.1 {
catchcmd "test.db" ".print this is a test"
} {0 {this is a test}}
# dot-command argument quoting
do_test shell1-3-30.1 {
catchcmd {test.db} {.print "this\"is'a\055test" 'this\"is\\a\055test'}
} {0 {this"is'a-test this\"is\\a\055test}}
do_test shell1-3-31.1 {
catchcmd {test.db} {.print "this\nis\ta\\test" 'this\nis\ta\\test'}
} [list 0 "this\nis\ta\\test this\\nis\\ta\\\\test"]
# Test the output of the ".dump" command
#
do_test shell1-4.1 {