diff --git a/vendor.mod b/vendor.mod index b97eb6108f48..4da92d2d8f4d 100644 --- a/vendor.mod +++ b/vendor.mod @@ -30,7 +30,7 @@ require ( github.com/moby/go-archive v0.2.0 github.com/moby/moby/api v1.54.0 github.com/moby/moby/client v0.3.0 - github.com/moby/patternmatcher v0.6.0 + github.com/moby/patternmatcher v0.6.1 github.com/moby/swarmkit/v2 v2.1.1 github.com/moby/sys/atomicwriter v0.1.0 github.com/moby/sys/capability v0.4.0 diff --git a/vendor.sum b/vendor.sum index 0cd9f5005471..5921aac1c0da 100644 --- a/vendor.sum +++ b/vendor.sum @@ -117,8 +117,8 @@ github.com/moby/moby/api v1.54.0 h1:7kbUgyiKcoBhm0UrWbdrMs7RX8dnwzURKVbZGy2GnL0= github.com/moby/moby/api v1.54.0/go.mod h1:8mb+ReTlisw4pS6BRzCMts5M49W5M7bKt1cJy/YbAqc= github.com/moby/moby/client v0.3.0 h1:UUGL5okry+Aomj3WhGt9Aigl3ZOxZGqR7XPo+RLPlKs= github.com/moby/moby/client v0.3.0/go.mod h1:HJgFbJRvogDQjbM8fqc1MCEm4mIAGMLjXbgwoZp6jCQ= -github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= -github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= +github.com/moby/patternmatcher v0.6.1 h1:qlhtafmr6kgMIJjKJMDmMWq7WLkKIo23hsrpR3x084U= +github.com/moby/patternmatcher v0.6.1/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= github.com/moby/swarmkit/v2 v2.1.1 h1:yvTJ8MMCc3f0qTA44J6R59EZ5yZawdYopkpuLk4+ICU= github.com/moby/swarmkit/v2 v2.1.1/go.mod h1:mTTGIAz/59OGZR5Qe+QByIe3Nxc+sSuJkrsStFhr6Lg= github.com/moby/sys/atomicwriter v0.1.0 h1:kw5D/EqkBwsBFi0ss9v1VG3wIkVhzGvLklJ+w3A14Sw= diff --git a/vendor/github.com/moby/patternmatcher/patternmatcher.go b/vendor/github.com/moby/patternmatcher/patternmatcher.go index 37a1a59ac4e3..216dea671eb4 100644 --- a/vendor/github.com/moby/patternmatcher/patternmatcher.go +++ b/vendor/github.com/moby/patternmatcher/patternmatcher.go @@ -331,14 +331,20 @@ func (p *Pattern) match(path string) (bool, error) { // **/foo matches "foo" return suffix[0] == os.PathSeparator && path == suffix[1:], nil case regexpMatch: + if p.regexp == nil { + return false, filepath.ErrBadPattern + } return p.regexp.MatchString(path), nil + case unknownMatch: + return false, filepath.ErrBadPattern + default: + return false, nil } - - return false, nil } func (p *Pattern) compile(sl string) error { regStr := "^" + detectedType := exactMatch // assume exact match pattern := p.cleanedPattern // Go through the pattern and convert it to a regexp. // We use a scanner so we can support utf-8 chars. @@ -350,7 +356,6 @@ func (p *Pattern) compile(sl string) error { escSL += `\` } - p.matchType = exactMatch for i := 0; scan.Peek() != scanner.EOF; i++ { ch := scan.Next() @@ -366,32 +371,32 @@ func (p *Pattern) compile(sl string) error { if scan.Peek() == scanner.EOF { // is "**EOF" - to align with .gitignore just accept all - if p.matchType == exactMatch { - p.matchType = prefixMatch + if detectedType == exactMatch { + detectedType = prefixMatch } else { regStr += ".*" - p.matchType = regexpMatch + detectedType = regexpMatch } } else { // is "**" // Note that this allows for any # of /'s (even 0) because // the .* will eat everything, even /'s regStr += "(.*" + escSL + ")?" - p.matchType = regexpMatch + detectedType = regexpMatch } if i == 0 { - p.matchType = suffixMatch + detectedType = suffixMatch } } else { // is "*" so map it to anything but "/" regStr += "[^" + escSL + "]*" - p.matchType = regexpMatch + detectedType = regexpMatch } } else if ch == '?' { // "?" is any char except "/" regStr += "[^" + escSL + "]" - p.matchType = regexpMatch + detectedType = regexpMatch } else if shouldEscape(ch) { // Escape some regexp special chars that have no meaning // in golang's filepath.Match @@ -408,31 +413,29 @@ func (p *Pattern) compile(sl string) error { } if scan.Peek() != scanner.EOF { regStr += `\` + string(scan.Next()) - p.matchType = regexpMatch + detectedType = regexpMatch } else { regStr += `\` } } else if ch == '[' || ch == ']' { regStr += string(ch) - p.matchType = regexpMatch + detectedType = regexpMatch } else { regStr += string(ch) } } - if p.matchType != regexpMatch { - return nil - } + if detectedType == regexpMatch { + regStr += "$" - regStr += "$" + re, err := regexp.Compile(regStr) + if err != nil { + return err + } - re, err := regexp.Compile(regStr) - if err != nil { - return err + p.regexp = re } - - p.regexp = re - p.matchType = regexpMatch + p.matchType = detectedType return nil } diff --git a/vendor/modules.txt b/vendor/modules.txt index ae9356be8241..15b577583cdd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -200,7 +200,7 @@ github.com/moby/moby/client/pkg/security github.com/moby/moby/client/pkg/streamformatter github.com/moby/moby/client/pkg/stringid github.com/moby/moby/client/pkg/versions -# github.com/moby/patternmatcher v0.6.0 +# github.com/moby/patternmatcher v0.6.1 ## explicit; go 1.19 github.com/moby/patternmatcher github.com/moby/patternmatcher/ignorefile