90f8d1b675
(*PatternMatcher).Matches includes a special case for when the pattern matches a parent dir, even though it doesn't match the current path. However, it assumes that the parent dir which would match the pattern must have the same number of separators as the pattern itself. This doesn't hold true with a patern like "**/foo". A file foo/bar would have len(parentPathDirs) == 1, which is less than the number of path len(pattern.dirs) == 2... therefore this check would be skipped. Given that "**/foo" matches "foo", I think it's a bug that the "parent subdir matches" check is being skipped in this case. It seems safer to loop over the parent subdirs and check each against the pattern. It's possible there is a safe optimization to check only a certain subset, but the existing logic seems unsafe. Signed-off-by: Aaron Lehmann <alehmann@netflix.com> |
||
---|---|---|
.. | ||
fileutils.go | ||
fileutils_darwin.go | ||
fileutils_test.go | ||
fileutils_unix.go | ||
fileutils_windows.go |