Fix Glob handling of backslashes

\m\a\t\c\h\.\g\o would be interpreted as a literal path, because the
backslash was missing in the check.
This commit is contained in:
greatroar 2021-03-15 18:11:02 +01:00
parent 413dd37571
commit d3695c2587
2 changed files with 2 additions and 2 deletions

View File

@ -1882,6 +1882,7 @@ var globTests = []struct {
{"match.go", "match.go"}, {"match.go", "match.go"},
{"mat?h.go", "match.go"}, {"mat?h.go", "match.go"},
{"ma*ch.go", "match.go"}, {"ma*ch.go", "match.go"},
{`\m\a\t\c\h\.\g\o`, "match.go"},
{"../*/match.go", "../sftp/match.go"}, {"../*/match.go", "../sftp/match.go"},
} }

View File

@ -133,6 +133,5 @@ func Join(elem ...string) string {
// hasMeta reports whether path contains any of the magic characters // hasMeta reports whether path contains any of the magic characters
// recognized by Match. // recognized by Match.
func hasMeta(path string) bool { func hasMeta(path string) bool {
// TODO(niemeyer): Should other magic characters be added here? return strings.ContainsAny(path, "\\*?[")
return strings.ContainsAny(path, "*?[")
} }