Skip to content

Commit 3f4f17b

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b8767f7 commit 3f4f17b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

diff.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3654,7 +3654,12 @@ static void enable_patch_output(int *fmt) {
36543654

36553655
static int parse_one_token(const char **arg, const char *token)
36563656
{
3657-
return skip_prefix(*arg, token, arg) && (!**arg || **arg == ',');
3657+
const char *rest;
3658+
if (skip_prefix(*arg, token, &rest) && (!*rest || *rest == ',')) {
3659+
*arg = rest;
3660+
return 1;
3661+
}
3662+
return 0;
36583663
}
36593664

36603665
static int parse_ws_error_highlight(struct diff_options *opt, const char *arg)

0 commit comments

Comments
 (0)