diff --git a/go.mod b/go.mod index ee41d2c3..bf8e3a19 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ replace k8s.io/code-generator => k8s.io/code-generator v0.29.9 require ( carvel.dev/ytt v0.50.0 github.com/ahmetb/gen-crd-api-reference-docs v0.3.0 - github.com/andybalholm/brotli v1.1.0 + github.com/andybalholm/brotli v1.1.1 github.com/gardener/gardener v1.105.0 github.com/go-logr/logr v1.4.2 github.com/spf13/cobra v1.8.1 diff --git a/go.sum b/go.sum index 416fb36b..bbed85ae 100644 --- a/go.sum +++ b/go.sum @@ -41,8 +41,8 @@ github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbt github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/ahmetb/gen-crd-api-reference-docs v0.3.0 h1:+XfOU14S4bGuwyvCijJwhhBIjYN+YXS18jrCY2EzJaY= github.com/ahmetb/gen-crd-api-reference-docs v0.3.0/go.mod h1:TdjdkYhlOifCQWPs1UdTma97kQQMozf5h26hTuG70u8= -github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= -github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= +github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= +github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= @@ -384,6 +384,8 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= +github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= +github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= diff --git a/vendor/github.com/andybalholm/brotli/encoder.go b/vendor/github.com/andybalholm/brotli/encoder.go index 650d1e42..19283825 100644 --- a/vendor/github.com/andybalholm/brotli/encoder.go +++ b/vendor/github.com/andybalholm/brotli/encoder.go @@ -21,6 +21,15 @@ func (e *Encoder) Encode(dst []byte, src []byte, matches []matchfinder.Match, la e.wroteHeader = true } + if len(src) == 0 { + if lastBlock { + e.bw.writeBits(2, 3) // islast + isempty + e.bw.jumpToByteBoundary() + return e.bw.dst + } + return dst + } + var literalHisto [256]uint32 var commandHisto [704]uint32 var distanceHisto [64]uint32 diff --git a/vendor/github.com/andybalholm/brotli/matchfinder/emitter.go b/vendor/github.com/andybalholm/brotli/matchfinder/emitter.go index 37ed8e13..507d1cae 100644 --- a/vendor/github.com/andybalholm/brotli/matchfinder/emitter.go +++ b/vendor/github.com/andybalholm/brotli/matchfinder/emitter.go @@ -32,14 +32,3 @@ func (e *matchEmitter) emit(m absoluteMatch) { }) e.NextEmit = m.End } - -// trim shortens m if it extends past maxEnd. Then if the length is at least -// minLength, the match is emitted. -func (e *matchEmitter) trim(m absoluteMatch, maxEnd int, minLength int) { - if m.End > maxEnd { - m.End = maxEnd - } - if m.End-m.Start >= minLength { - e.emit(m) - } -} diff --git a/vendor/github.com/andybalholm/brotli/matchfinder/m4.go b/vendor/github.com/andybalholm/brotli/matchfinder/m4.go index 5b2acba2..81894725 100644 --- a/vendor/github.com/andybalholm/brotli/matchfinder/m4.go +++ b/vendor/github.com/andybalholm/brotli/matchfinder/m4.go @@ -56,7 +56,7 @@ func (q *M4) Reset() { } func (q *M4) score(m absoluteMatch) int { - return (m.End-m.Start)*256 + bits.LeadingZeros32(uint32(m.Start-m.Match))*q.DistanceBitCost + return (m.End-m.Start)*256 + (bits.LeadingZeros32(uint32(m.Start-m.Match))-32)*q.DistanceBitCost } func (q *M4) FindMatches(dst []Match, src []byte) []Match { @@ -112,7 +112,12 @@ func (q *M4) FindMatches(dst []Match, src []byte) []Match { // We have found some matches, and we're far enough along that we probably // won't find overlapping matches, so we might as well emit them. if matches[1] != (absoluteMatch{}) { - e.trim(matches[1], matches[0].Start, q.MinLength) + if matches[1].End > matches[0].Start { + matches[1].End = matches[0].Start + } + if matches[1].End-matches[1].Start >= q.MinLength && q.score(matches[1]) > 0 { + e.emit(matches[1]) + } } e.emit(matches[0]) matches = [3]absoluteMatch{} @@ -139,12 +144,10 @@ func (q *M4) FindMatches(dst []Match, src []byte) []Match { // Look for a match. var currentMatch absoluteMatch - if i-candidate != matches[0].Start-matches[0].Match { - if binary.LittleEndian.Uint32(src[candidate:]) == binary.LittleEndian.Uint32(src[i:]) { - m := extendMatch2(src, i, candidate, e.NextEmit) - if m.End-m.Start > q.MinLength { - currentMatch = m - } + if binary.LittleEndian.Uint32(src[candidate:]) == binary.LittleEndian.Uint32(src[i:]) { + m := extendMatch2(src, i, candidate, e.NextEmit) + if m.End-m.Start > q.MinLength && q.score(m) > 0 { + currentMatch = m } } @@ -157,12 +160,10 @@ func (q *M4) FindMatches(dst []Match, src []byte) []Match { if candidate <= 0 || i-candidate > q.MaxDistance { break } - if i-candidate != matches[0].Start-matches[0].Match { - if binary.LittleEndian.Uint32(src[candidate:]) == binary.LittleEndian.Uint32(src[i:]) { - m := extendMatch2(src, i, candidate, e.NextEmit) - if m.End-m.Start > q.MinLength && q.score(m) > q.score(currentMatch) { - currentMatch = m - } + if binary.LittleEndian.Uint32(src[candidate:]) == binary.LittleEndian.Uint32(src[i:]) { + m := extendMatch2(src, i, candidate, e.NextEmit) + if m.End-m.Start > q.MinLength && q.score(m) > q.score(currentMatch) { + currentMatch = m } } } @@ -217,14 +218,24 @@ func (q *M4) FindMatches(dst []Match, src []byte) []Match { default: // Emit the first match, shortening it if necessary to avoid overlap with the second. - e.trim(matches[2], matches[1].Start, q.MinLength) + if matches[2].End > matches[1].Start { + matches[2].End = matches[1].Start + } + if matches[2].End-matches[2].Start >= q.MinLength && q.score(matches[2]) > 0 { + e.emit(matches[2]) + } matches[2] = absoluteMatch{} } } // We've found all the matches now; emit the remaining ones. if matches[1] != (absoluteMatch{}) { - e.trim(matches[1], matches[0].Start, q.MinLength) + if matches[1].End > matches[0].Start { + matches[1].End = matches[0].Start + } + if matches[1].End-matches[1].Start >= q.MinLength && q.score(matches[1]) > 0 { + e.emit(matches[1]) + } } if matches[0] != (absoluteMatch{}) { e.emit(matches[0]) diff --git a/vendor/modules.txt b/vendor/modules.txt index e5eb0d2e..04b9804c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -39,7 +39,7 @@ github.com/Masterminds/sprig/v3 # github.com/ahmetb/gen-crd-api-reference-docs v0.3.0 ## explicit; go 1.15 github.com/ahmetb/gen-crd-api-reference-docs -# github.com/andybalholm/brotli v1.1.0 +# github.com/andybalholm/brotli v1.1.1 ## explicit; go 1.13 github.com/andybalholm/brotli github.com/andybalholm/brotli/matchfinder