Year Field missing when one exists

Issue #42 resolved
IJabz repo owner created an issue

From https://java.net/jira/browse/JAUDIOTAGGER-481

Have come across an audio file that has a year field in it of 2005 and is shown by all my other tagging apps correctly. When i process it with jaudiotagger it fails to find the year. hasField() returns false

Rogue file can be downloaded at: https://content.soundideas.co.uk/public/bad_year_metadata.mp3

After quick look at source code, it appears the potential problems lies in TyerTdatAggregatedFrame.java as tdat is coming through as empty string and following code doesn't check for this causing an exception to be thrown internally.

Possible solution: check tdat is not empty

public class TyerTdatAggregatedFrame extends AggregatedFrame
{
public static final String ID_TYER_TDAT = ID3v23Frames.FRAME_ID_V3_TYER+ID3v23Frames.FRAME_ID_V3_TDAT;
public String getContent()
{ 
StringBuilder sb = new StringBuilder();
 Iterator<AbstractID3v2Frame> i = frames.iterator(); 
AbstractID3v2Frame tyer = i.next();
 sb.append(tyer.getContent());
 AbstractID3v2Frame tdat = i.next();
 sb.append("-"); //tdat content is an empty string! sb.append(tdat.getContent().substring(2,4));
 sb.append("-"); 
sb.append(tdat.getContent().substring(0,2)); 
return sb.toString(); 
}

}

Comments (5)

  1. IJabz reporter

    Replicated, the error occurs not at contruction but when try and read year value from tag

    i.e

    java.lang.StringIndexOutOfBoundsException: String index out of range: 4
        at java.lang.String.substring(String.java:1950)
        at org.jaudiotagger.tag.id3.TyerTdatAggregatedFrame.getContent(TyerTdatAggregatedFrame.java:27)
        at org.jaudiotagger.tag.id3.ID3v23Tag.getValue(ID3v23Tag.java:1132)
        at org.jaudiotagger.tag.id3.AbstractID3v2Tag.getFirst(AbstractID3v2Tag.java:2126)
    
  2. IJabz reporter

    Fixed original issue, additionally just ignore FrameBodyTDAT if actually empty rather than compilcating things by constructing a TYERTDAT aggregate frame.

  3. Log in to comment