n10v / id3v2

🎵 ID3 decoding and encoding library for Go
https://pkg.go.dev/github.com/bogem/id3v2/v2
MIT License
334 stars 50 forks source link

There is a bug in handling duplicates in your package. #42

Closed AlexisWilke closed 4 years ago

AlexisWilke commented 4 years ago

As I was writing a test, I noticed that in most cases you keep the first instance of a tag. All the others will be ignored.

I did not test all the tags or look at your code, but some tags can and are even expected to be duplicated.

Specifically, the TXXX tag has to be distinguished from its label and not the tag itself.

You add tag function works:

id3Tag.AddUserDefinedTextFrame(someFrame)

since it adds a new tag. However, it works the other way around: it accepts new entries which are potentially duplicates.

So... if you find two entries that looks like:

TXXX <size> <flags> 3 <name> \0 <data>

and the <name> are different, keep both in the order they were added. If the user calls AddUserDefinedText(). The reading of the tags should probably make use of the same add functions so that way you do not have to repeat that logic everywhere.

Documentation: http://id3.org/id3v2.3.0#User_defined_text_information_frame

n10v commented 4 years ago

This can be fixed in https://github.com/bogem/id3v2/commit/4de0eaa0900aa89d4fd9abeed5aaf8cf6e6d5d5d. Please check

n10v commented 4 years ago

Added tests for it: https://github.com/bogem/id3v2/commit/0a57fbfd454e5af70820fa8f650a099afd6d6f1b#diff-e205654706d74dd8d206fc612c290191R77. Thank you for bug report!