mirror of https://github.com/pkg/sftp.git
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:
parent
413dd37571
commit
d3695c2587
|
@ -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"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
match.go
3
match.go
|
@ -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, "*?[")
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue