Skip to content

Commit

Permalink
Be a little less strict on invalid frames
Browse files Browse the repository at this point in the history
Add iTunes frames and ignore unknown frame instead of bypassing all remaining
frames
  • Loading branch information
xhenner committed Jul 5, 2015
1 parent 334c710 commit 1e60a81
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
19 changes: 14 additions & 5 deletions id3v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,6 @@ func readID3v2Frames(r io.Reader, h *id3v2Header) (map[string]interface{}, error
return nil, err
}

// Avoid corrupted padding (see http://id3.org/Compliance%20Issues).
if !validID3Frame(h.Version, name) {
break
}

// FIXME: Do we still need this?
// if size=0, we certainly are in a padding zone. ignore the rest of
// the tags
Expand All @@ -233,6 +228,20 @@ func readID3v2Frames(r io.Reader, h *id3v2Header) (map[string]interface{}, error

offset += headerSize + size

// Avoid corrupted padding (see http://id3.org/Compliance%20Issues).
if !validID3Frame(h.Version, name) {
// There is a real problem with this frame
if offset > h.Size {
break
}

// just ignore this frame, maybe it's just a proprietary one
if _, err = readBytes(r, size); err != nil {
return nil, err
}
continue
}

if flags != nil {
if flags.Compression {
_, err = read7BitChunkedInt(r, 4) // read 4
Expand Down
6 changes: 6 additions & 0 deletions id3v2frames.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ var id3v23Frames = map[string]string{
"SYTC": "Synchronized tempo codes",
"TALB": "Album/Movie/Show title",
"TBPM": "BPM (beats per minute)",
"TCMP": "iTunes Compilation Flag",
"TCOM": "Composer",
"TCON": "Content type",
"TCOP": "Copyright message",
Expand Down Expand Up @@ -152,6 +153,8 @@ var id3v23Frames = map[string]string{
"TRSN": "Internet radio station name",
"TRSO": "Internet radio station owner",
"TSIZ": "Size",
"TSO2": "iTunes uses this for Album Artist sort order",
"TSOC": "iTunes uses this for Composer sort order",
"TSRC": "ISRC (international standard recording code)",
"TSSE": "Software/Hardware and settings used for encoding",
"TYER": "Year",
Expand Down Expand Up @@ -209,6 +212,7 @@ var id3v24Frames = map[string]string{

"TALB": "Album/Movie/Show title",
"TBPM": "BPM (beats per minute)",
"TCMP": "iTunes Compilation Flag",
"TCOM": "Composer",
"TCON": "Content type",
"TCOP": "Copyright message",
Expand Down Expand Up @@ -246,7 +250,9 @@ var id3v24Frames = map[string]string{
"TRCK": "Track number/Position in set",
"TRSN": "Internet radio station name",
"TRSO": "Internet radio station owner",
"TSO2": "iTunes uses this for Album Artist sort order",
"TSOA": "Album sort order",
"TSOC": "iTunes uses this for Composer sort order",
"TSOP": "Performer sort order",
"TSOT": "Title sort order",
"TSRC": "ISRC (international standard recording code)",
Expand Down

0 comments on commit 1e60a81

Please sign in to comment.