From 88a347dce0b8e2f53faf1a8f12d7529b49fad24f Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Sun, 7 Dec 2014 00:10:32 +0000 Subject: [PATCH] Escape plus sign (fixes #1090) --- internal/fnmatch/fnmatch.go | 1 + internal/ignore/ignore_test.go | 2 ++ internal/ignore/testdata/.stignore | 1 + 3 files changed, 4 insertions(+) diff --git a/internal/fnmatch/fnmatch.go b/internal/fnmatch/fnmatch.go index db87e1d1..df19b29d 100644 --- a/internal/fnmatch/fnmatch.go +++ b/internal/fnmatch/fnmatch.go @@ -55,6 +55,7 @@ func Convert(pattern string, flags int) (*regexp.Regexp, error) { pattern = strings.Replace(pattern, "\\.", "[:escapeddot:]", -1) } pattern = strings.Replace(pattern, ".", "\\.", -1) + pattern = strings.Replace(pattern, "+", "\\+", -1) pattern = strings.Replace(pattern, "**", "[:doublestar:]", -1) pattern = strings.Replace(pattern, "*", any+"*", -1) pattern = strings.Replace(pattern, "[:doublestar:]", ".*", -1) diff --git a/internal/ignore/ignore_test.go b/internal/ignore/ignore_test.go index dcf15308..8c5624e5 100644 --- a/internal/ignore/ignore_test.go +++ b/internal/ignore/ignore_test.go @@ -55,6 +55,8 @@ func TestIgnore(t *testing.T) { {filepath.Join("dir3"), true}, {filepath.Join("dir3", "afile"), true}, + + {"lost+found", true}, } for i, tc := range tests { diff --git a/internal/ignore/testdata/.stignore b/internal/ignore/testdata/.stignore index 89a11f4b..b6f4d665 100644 --- a/internal/ignore/testdata/.stignore +++ b/internal/ignore/testdata/.stignore @@ -4,3 +4,4 @@ bfile dir1/cfile **/efile /ffile +lost+found