Skip to content

node-taglib-sharp incorrectly parses genres if it starts with numbers #122

@digimezzo

Description

@digimezzo

The attached file contains a genre 20er Jahre. The user that provided this file, likes to organize genre by decade.
During parsing of the TCON field in textInformationFrame.ts, there is this piece of code:

if (Id3v2Settings.useNonStandardV2V3NumericGenres) {
    const text = Genres.indexToAudio(v2, false);
    if (text) {
        v2 = text;
    }
} 

v2 contains 20er Jahre, which is passed to Genres.indexToAudio. This is the code for indexToAudio:

public static indexToAudio(index: number|string, allowParenthesis: boolean): string {
        const safeIndex = typeof(index) === "string"
            ? Genres.stringToByte(index, allowParenthesis)
            : index;
        return Number.isSafeInteger(safeIndex) && safeIndex < Genres.AUDIO_GENRES.length && safeIndex >= 0
            ? Genres.AUDIO_GENRES[safeIndex]
            : undefined;
    }

index contains 20er Jahre, which is converted to safeIndex=20. Index 20 in Genres.AUDIO_GENRES= 'Alternative', which is returned as genre.

The file in question: genre tag test.mp3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions