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>
René Scharfe committed
Jul 11, 2015 at 14:58 UTC
3f4f17b51b30262041a2248ef9f966f6248aed50
1 file changed
+6
-1
diff.c
+6
-1
@@ -3654,7 +3654,12 @@ static void enable_patch_output(int *fmt) {
3654
3655
static int parse_one_token(const char **arg, const char *token)
3656
{
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;
3663
}
3664
3665
static int parse_ws_error_highlight(struct diff_options *opt, const char *arg)