From e53ffe2704d7e10690f4382e46c1411a482531f1 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Fri, 31 Jan 2020 20:16:13 +0000 Subject: sparse-checkout: escape all glob characters on write The sparse-checkout patterns allow special globs according to fnmatch(3). When writing cone-mode patterns for paths containing these characters, they must be escaped. Use is_glob_special() to check which characters must be escaped this way, and add a path to the tests that contains all glob characters at once. Note that ']' is not special, since the initial bracket '[' is escaped. Reported-by: Jeff King Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- builtin/sparse-checkout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/sparse-checkout.c') diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index facdb6bda7..7aeb384362 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -149,7 +149,7 @@ static char *escaped_pattern(char *pattern) struct strbuf final = STRBUF_INIT; while (*p) { - if (*p == '*' || *p == '\\') + if (is_glob_special(*p)) strbuf_addch(&final, '\\'); strbuf_addch(&final, *p); -- cgit v1.2.3