diff --git a/id3v1.go b/id3v1.go index 3703a7d..e9e5d17 100644 --- a/id3v1.go +++ b/id3v1.go @@ -54,17 +54,17 @@ func ReadID3v1Tags(r io.ReadSeeker) (Metadata, error) { return nil, ErrNotID3v1 } - title, err := readString(r, 30) + title, err := readStringTrimNULL(r, 30) if err != nil { return nil, err } - artist, err := readString(r, 30) + artist, err := readStringTrimNULL(r, 30) if err != nil { return nil, err } - album, err := readString(r, 30) + album, err := readStringTrimNULL(r, 30) if err != nil { return nil, err } diff --git a/util.go b/util.go index 4858802..4278ce9 100644 --- a/util.go +++ b/util.go @@ -43,6 +43,14 @@ func readBytes(r io.Reader, n int) ([]byte, error) { } func readString(r io.Reader, n int) (string, error) { + b, err := readBytes(r, n) + if err != nil { + return "", err + } + return string(b), nil +} + +func readStringTrimNULL(r io.Reader, n int) (string, error) { b, err := readBytes(r, n) if err != nil { return "", err