diff --git a/src/restic/filter/filter.go b/src/restic/filter/filter.go index bb483d31c..37b58f7ef 100644 --- a/src/restic/filter/filter.go +++ b/src/restic/filter/filter.go @@ -100,9 +100,14 @@ func match(patterns, strs []string) (matched bool, err error) { return false, nil } -// List returns true if str matches one of the patterns. +// List returns true if str matches one of the patterns. Empty patterns are +// ignored. func List(patterns []string, str string) (matched bool, err error) { for _, pat := range patterns { + if pat == "" { + continue + } + matched, err = Match(pat, str) if err != nil { return false, err diff --git a/src/restic/filter/filter_test.go b/src/restic/filter/filter_test.go index 2fb04cdf5..232e2c4d3 100644 --- a/src/restic/filter/filter_test.go +++ b/src/restic/filter/filter_test.go @@ -152,6 +152,7 @@ var filterListTests = []struct { {[]string{"?", "x"}, "/foo/bar/x", true}, {[]string{"/*/*/bar/test.*"}, "/foo/bar/test.go", false}, {[]string{"/*/*/bar/test.*", "*.go"}, "/foo/bar/test.go", true}, + {[]string{"", "*.c"}, "/foo/bar/test.go", false}, } func TestMatchList(t *testing.T) {