From 0e51ec1699f54fb18c3d156cb293d3fa720d305d Mon Sep 17 00:00:00 2001 From: Robin Neatherway Date: Thu, 19 Aug 2021 14:41:04 +0100 Subject: [PATCH] Correct benign mistake in off-by-one guard m[2] is the third element of m, rather than the second, so we have to check instead that the len of m is at least 3. Because the regular expression has two capture groups, the length of m will always be 3, so currently the guard will always be true. --- pkg/cmd/api/pagination.go | 2 +- pkg/cmd/secret/list/list.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/api/pagination.go b/pkg/cmd/api/pagination.go index fce88fb92..65d816480 100644 --- a/pkg/cmd/api/pagination.go +++ b/pkg/cmd/api/pagination.go @@ -14,7 +14,7 @@ var linkRE = regexp.MustCompile(`<([^>]+)>;\s*rel="([^"]+)"`) func findNextPage(resp *http.Response) (string, bool) { for _, m := range linkRE.FindAllStringSubmatch(resp.Header.Get("Link"), -1) { - if len(m) >= 2 && m[2] == "next" { + if len(m) > 2 && m[2] == "next" { return m[1], true } } diff --git a/pkg/cmd/secret/list/list.go b/pkg/cmd/secret/list/list.go index 35d8db675..c2f814782 100644 --- a/pkg/cmd/secret/list/list.go +++ b/pkg/cmd/secret/list/list.go @@ -250,7 +250,7 @@ var linkRE = regexp.MustCompile(`<([^>]+)>;\s*rel="([^"]+)"`) func findNextPage(link string) string { for _, m := range linkRE.FindAllStringSubmatch(link, -1) { - if len(m) >= 2 && m[2] == "next" { + if len(m) > 2 && m[2] == "next" { return m[1] } }