From 10b817df2e89460483a1b643bee7153dfd24ced7 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 1 Oct 2023 06:36:47 +0400 Subject: [PATCH] In oggtag handle a case when tag name are in upper case. --- pkg/oggtag/oggtag.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/oggtag/oggtag.go b/pkg/oggtag/oggtag.go index 7fcf8aa..47d344a 100644 --- a/pkg/oggtag/oggtag.go +++ b/pkg/oggtag/oggtag.go @@ -6,6 +6,7 @@ for certain tag names ending with an = character, e.g. artist= and title=. import ( "bytes" + "strings" ) // OggGetTag is searching for a certain tag in a given buffer buf and returns @@ -15,7 +16,14 @@ import ( // looking for a certain tag preceded with three zero bytes and ends with // an = character. func OggGetTag(buf []byte, tag string) string { - tagIdx := bytes.Index(buf, append([]byte{0, 0, 0}, (tag+"=")...)) + 3 + tagIdx := bytes.Index(buf, append([]byte{0, 0, 0}, (tag+"=")...)) + if tagIdx == -1 { + tagIdx = bytes.Index(buf, append([]byte{0, 0, 0}, (strings.ToUpper(tag)+"=")...)) + if tagIdx == -1 { + return "" + } + } + tagIdx += 3 tagNameLen := len(tag) + 1 valStart := tagIdx + tagNameLen valLen := int(buf[tagIdx-4]) - tagNameLen