Skip to content

Commit

Permalink
diff: parse ws-error-highlight option more strictly
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Jul 12, 2015
1 parent b8767f7 commit 3f4f17b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3f4f17b

Please sign in to comment.