diff: parse ws-error-highlight option more strictly

Check if a matched token is followed by a delimiter before advancing the
pointer arg.  This avoids accepting composite words like "allnew" or
"defaultcontext" and misparsing them as "new" or "context".

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe 2015-07-11 14:58:21 +02:00 committed by Junio C Hamano
parent b8767f791c
commit 3f4f17b51b

7
diff.c
View File

@ -3654,7 +3654,12 @@ static void enable_patch_output(int *fmt) {
static int parse_one_token(const char **arg, const char *token)
{
return skip_prefix(*arg, token, arg) && (!**arg || **arg == ',');
const char *rest;
if (skip_prefix(*arg, token, &rest) && (!*rest || *rest == ',')) {
*arg = rest;
return 1;
}
return 0;
}
static int parse_ws_error_highlight(struct diff_options *opt, const char *arg)