[prev in list] [next in list] [prev in thread] [next in thread] 

List:       taglib-devel
Subject:    Re: [PATCH] Fix handling of ID3v2.3 text frames
From:       "Xavier Duret" <xaviour.maillists () gmail ! com>
Date:       2007-01-19 15:35:36
Message-ID: d3ef58310701190735i6fd97e12w520dee91cd9159a4 () mail ! gmail ! com
[Download RAW message or body]

This update of the previous patch also get rid of trailing zeros that
are allowed in ID3v2.3. Trailing zeros is not a common behavior but I
do have an example of it.

diff -ruN taglib.old/taglib/mpeg/id3v2/frames/textidentificationframe.cpp
taglib/taglib/mpeg/id3v2/frames/textidentificationframe.cpp
--- taglib.old/taglib/mpeg/id3v2/frames/textidentificationframe.cpp
 2007-01-17 16:01:34.000000000 +0100
+++ taglib/taglib/mpeg/id3v2/frames/textidentificationframe.cpp
2007-01-19 14:40:56.000000000 +0100
@@ -94,16 +94,26 @@

 void TextIdentificationFrame::parseFields(const ByteVector &data)
 {
+  ByteVector fixedData;
+  uint i = 0;
+
   // read the string data type (the first byte of the field data)

   d->textEncoding = String::Type(data[0]);
+  int byteAlign = d->textEncoding == String::Latin1 ||
d->textEncoding == String::UTF8 ? 1 : 2;
+
+  // Strip trailing zeros for ID3v2.3
+
+  while((i<data.size()) && (data.mid(data.size() - i - 1, 1) ==
ByteVector(1,0)))
+    i++;
+  if ((byteAlign == 2) && ((i % 2) == 1))
+    i--;
+  fixedData = data.mid(0, data.size() - i);

   // split the byte array into chunks based on the string type (two
byte delimiter
   // for unicode encodings)

-  int byteAlign = d->textEncoding == String::Latin1 ||
d->textEncoding == String::UTF8 ? 1 : 2;
-
-  ByteVectorList l = ByteVectorList::split(data.mid(1),
textDelimiter(d->textEncoding), byteAlign);
+  ByteVectorList l = ByteVectorList::split(fixedData.mid(1),
textDelimiter(d->textEncoding), byteAlign);

   d->fieldList.clear();


On 1/17/07, Xavier Duret <xaviour.maillists@gmail.com> wrote:
> 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).
_______________________________________________
taglib-devel mailing list
taglib-devel@kde.org
https://mail.kde.org/mailman/listinfo/taglib-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic