isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit 17c4748dfa347389099844ae48c7cb51dbac026c
parent 2213d6976c8247d0e746f14123fbe6030a80c759
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Wed, 25 Sep 2013 20:56:52 +0200

support backslash-escaping in the config file

note that no attempt is made at making this work in the compat wrapper.

Diffstat:
Msrc/config.c | 16+++++++++++++---
Msrc/mbsync.1 | 3++-
2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/config.c b/src/config.c @@ -48,7 +48,7 @@ static char * get_arg( conffile_t *cfile, int required, int *comment ) { char *ret, *p, *t; - int quoted; + int escaped, quoted; char c; p = cfile->rest; @@ -64,9 +64,14 @@ get_arg( conffile_t *cfile, int required, int *comment ) } ret = 0; } else { - for (quoted = 0, ret = t = p; c; c = *p) { + for (escaped = 0, quoted = 0, ret = t = p; c; c = *p) { p++; - if (c == '"') + if (escaped && c >= 32) { + escaped = 0; + *t++ = c; + } else if (c == '\\') + escaped = 1; + else if (c == '"') quoted ^= 1; else if (!quoted && isspace( (unsigned char) c )) break; @@ -74,6 +79,11 @@ get_arg( conffile_t *cfile, int required, int *comment ) *t++ = c; } *t = 0; + if (escaped) { + error( "%s:%d: unterminated escape sequence\n", cfile->file, cfile->line ); + cfile->err = 1; + ret = 0; + } if (quoted) { error( "%s:%d: missing closing quote\n", cfile->file, cfile->line ); cfile->err = 1; diff --git a/src/mbsync.1 b/src/mbsync.1 @@ -88,7 +88,8 @@ If specified twice, suppress warning messages as well. The configuration file is mandatory; \fBmbsync\fR will not run without it. Lines starting with a hash mark (\fB#\fR) are comments and are ignored entirely. Configuration items are keywords followed by one or more arguments; -arguments containing spaces must be enclosed in double quotes (\fB"\fR). +arguments containing spaces must be enclosed in double quotes (\fB"\fR), +and literal double quotes and backslashes (\fB\\\fR) must be backslash-escaped. All keywords (including those used as arguments) are case-insensitive. Bash-like home directory expansion using the tilde (\fB~\fR) is supported in all options which represent local paths.