From 3f4f17b51b30262041a2248ef9f966f6248aed50 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 11 Jul 2015 14:58:21 +0200 Subject: [PATCH] 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 Signed-off-by: Junio C Hamano --- diff.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/diff.c b/diff.c index 34012b4b63..8af01f149d 100644 --- a/diff.c +++ b/diff.c @@ -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) -- 2.11.4.GIT