mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 10:58:55 +00:00
filter: Fix glob matching on absolute path marker on windows
A pattern part containing "/" is used to mark a path or a pattern as absolute. However, on Windows the path separator is "\" such that glob patterns like "?" could match the marker. The code now explicitly skips the marker when the pattern does not represent an absolute path.
This commit is contained in:
parent
740758a5fa
commit
88c8e903d2
@ -167,13 +167,17 @@ func match(patterns Pattern, strs []string) (matched bool, err error) {
|
||||
}
|
||||
|
||||
if len(patterns) <= len(strs) {
|
||||
minOffset := 0
|
||||
maxOffset := len(strs) - len(patterns)
|
||||
// special case absolute patterns
|
||||
if patterns[0].pattern == "/" {
|
||||
maxOffset = 0
|
||||
} else if strs[0] == "/" {
|
||||
// skip absolute path marker if pattern is not rooted
|
||||
minOffset = 1
|
||||
}
|
||||
outer:
|
||||
for offset := maxOffset; offset >= 0; offset-- {
|
||||
for offset := maxOffset; offset >= minOffset; offset-- {
|
||||
|
||||
for i := len(patterns) - 1; i >= 0; i-- {
|
||||
var ok bool
|
||||
|
Loading…
Reference in New Issue
Block a user