From 75ffa7b77f19db10dbb3ed21d7eb39b7b025864f Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Thu, 7 Sep 2023 07:08:31 +0930 Subject: [PATCH] resolve semantic conflicts --- packetbeat/protos/http/http.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packetbeat/protos/http/http.go b/packetbeat/protos/http/http.go index 64294386ce82..25632172230b 100644 --- a/packetbeat/protos/http/http.go +++ b/packetbeat/protos/http/http.go @@ -20,7 +20,6 @@ package http import ( "bytes" "encoding/base64" - "errors" "fmt" "net" "net/url" @@ -760,13 +759,26 @@ func extractHostHeader(header string) (host string, port int) { } func trimSquareBracket(s string) string { - s, ok := strings.CutPrefix(s, "[") + s, ok := stringsCutPrefix(s, "[") if !ok { return s } return strings.TrimSuffix(s, "]") } +// stringsCutPrefix is copied from the standard library strings package as 7.17 is not built +// with go1.20 when strings.CutPrefix was added. +// +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +func stringsCutPrefix(s, prefix string) (after string, found bool) { + if !strings.HasPrefix(s, prefix) { + return s, false + } + return s[len(prefix):], true +} + func (http *httpPlugin) hideHeaders(m *message) { for _, header := range http.redactHeaders { if _, exists := m.headers[header]; exists {