summaryrefslogtreecommitdiff
path: root/quote.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-02-27 10:34:02 -0800
committerJunio C Hamano <gitster@pobox.com>2018-02-27 10:34:02 -0800
commit5aebb3e0ef7f06358d1ca224247a5fbc12e99ccc (patch)
tree0f87dd2f664fce3db950d422073eb914563b127b /quote.c
parentd7db100c18cf6ecdbe724938503b644e3ac8cde9 (diff)
parentddbbf8eb25065720eefeb31e22f668931fca815b (diff)
downloadgit-5aebb3e0ef7f06358d1ca224247a5fbc12e99ccc.tar.gz
Merge branch 'jk/sq-dequote-on-bogus-input'
Code to unquote single-quoted string (used in the parser for configuration files, etc.) did not diagnose bogus input correctly and produced bogus results instead. * jk/sq-dequote-on-bogus-input: sq_dequote: fix extra consumption of source string
Diffstat (limited to 'quote.c')
-rw-r--r--quote.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/quote.c b/quote.c
index 37d2686865..c95dd2cafb 100644
--- a/quote.c
+++ b/quote.c
@@ -118,9 +118,15 @@ static char *sq_dequote_step(char *arg, char **next)
*next = NULL;
return arg;
case '\\':
- c = *++src;
- if (need_bs_quote(c) && *++src == '\'') {
- *dst++ = c;
+ /*
+ * Allow backslashed characters outside of
+ * single-quotes only if they need escaping,
+ * and only if we resume the single-quoted part
+ * afterward.
+ */
+ if (need_bs_quote(src[1]) && src[2] == '\'') {
+ *dst++ = src[1];
+ src += 2;
continue;
}
/* Fallthrough */