]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Fix handling of a character class with an escaped closing bracket.
authorWayne Davison <wayne@opencoder.net>
Wed, 10 Aug 2022 00:51:00 +0000 (17:51 -0700)
committerWayne Davison <wayne@opencoder.net>
Wed, 10 Aug 2022 00:55:03 +0000 (17:55 -0700)
exclude.c

index ea1aa495baa963df41e34d9443a8042b577da92c..e57744204d746c40638f45c32c5606e4e7376e98 100644 (file)
--- a/exclude.c
+++ b/exclude.c
@@ -424,9 +424,10 @@ void add_implied_include(const char *arg, int skip_daemon_module)
                for (cp = arg; *cp; ) {
                        switch (*cp) {
                          case '\\':
-                               if (cp[1] == ']')
-                                       cp++; /* A \] in a filter might cause a problem w/o wildcards. */
-                               else if (!strchr("*[?", cp[1])) {
+                               if (cp[1] == ']') {
+                                       if (!saw_wild)
+                                               cp++; /* A \] in a non-wild filter causes a problem, so drop the \ . */
+                               } else if (!strchr("*[?", cp[1])) {
                                        backslash_cnt++;
                                        if (saw_wild)
                                                *p++ = '\\';