From a081f19c3026a6ef1c8045c9e351c6a32a424bdb Mon Sep 17 00:00:00 2001 From: Aleksey Sulzhenko Date: Sat, 18 Sep 2021 18:22:11 +0300 Subject: [PATCH] Fix UFID error: "expected to split UFID data into 2 pieces" (cherry picked from commit 02b288165e4fc288c84d48653483a0a59f46388c) --- id3v2.go | 5 +---- id3v2frames.go | 8 +++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/id3v2.go b/id3v2.go index cb6c662..96382d0 100644 --- a/id3v2.go +++ b/id3v2.go @@ -340,10 +340,7 @@ func readID3v2Frames(r io.Reader, offset uint, h *id3v2Header) (map[string]inter result[rawName] = txt case name == "UFID" || name == "UFI": - t, err := readUFID(b) - if err != nil { - return nil, err - } + t := readUFID(b) result[rawName] = t case name == "WXXX" || name == "WXX": diff --git a/id3v2frames.go b/id3v2frames.go index 8397eba..83958a6 100644 --- a/id3v2frames.go +++ b/id3v2frames.go @@ -505,16 +505,18 @@ func (u UFID) String() string { return fmt.Sprintf("%v (%v)", u.Provider, string(u.Identifier)) } -func readUFID(b []byte) (*UFID, error) { +func readUFID(b []byte) *UFID { result := bytes.SplitN(b, singleZero, 2) if len(result) != 2 { - return nil, errors.New("expected to split UFID data into 2 pieces") + return &UFID{ + Identifier: result[0], + } } return &UFID{ Provider: string(result[0]), Identifier: result[1], - }, nil + } } var pictureTypes = map[byte]string{