Fix UFID error: "expected to split UFID data into 2 pieces"

(cherry picked from commit 02b288165e4fc288c84d48653483a0a59f46388c)
This commit is contained in:
Aleksey Sulzhenko 2021-09-18 18:22:11 +03:00 committed by RedleX
parent d52dcb253c
commit a081f19c30
2 changed files with 6 additions and 7 deletions

View File

@ -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":

View File

@ -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{