[PATCH] Fix handling of ID3v2.3 text frames

Xavier Duret xaviour.maillists at gmail.com
Wed Jan 17 15:31:06 CET 2007


ID3v2.3 specifies that text information frames can be NULL terminated
(see section 4.2). The encoding of the strings themselves are
specified in section 3.3. This means that a frame like "54 52 43 4b 00
00 00 03 00 00 00 31 00 TRCK.......1." actually contains a single NULL
terminated string.
This patch makes ID3v2.3 text information frames behave like ID3v2.4
which in turn ensures that the parsing of "TRCK" tag works properly
(in the example, return 1 instead of 0).

diff -ruN taglib/mpeg/id3v2/frames/textidentificationframe.cpp.old
taglib/mpeg/id3v2/frames/textidentificationframe.cpp
--- taglib/mpeg/id3v2/frames/textidentificationframe.cpp.old
2007-01-17 14:51:25.000000000 +0100
+++ taglib/mpeg/id3v2/frames/textidentificationframe.cpp
2007-01-17 14:52:29.000000000 +0100
@@ -103,7 +103,13 @@

   int byteAlign = d->textEncoding == String::Latin1 ||
d->textEncoding == String::UTF8 ? 1 : 2;

-  ByteVectorList l = ByteVectorList::split(data.mid(1),
textDelimiter(d->textEncoding), byteAlign);
+  ByteVector fixedData;
+  if (data.mid(data.size() - byteAlign, byteAlign) ==
textDelimiter(d->textEncoding))
+    fixedData = data.mid(0, data.size() - byteAlign);
+  else
+    fixedData = data;
+
+  ByteVectorList l = ByteVectorList::split(fixedData.mid(1),
textDelimiter(d->textEncoding), byteAlign);

   d->fieldList.clear();


More information about the taglib-devel mailing list