]> granicus.if.org Git - taglib/commitdiff
Strip nulls from the end of ID3v2 text fields.
authorScott Wheeler <wheeler@kde.org>
Sun, 1 Apr 2007 22:08:44 +0000 (22:08 +0000)
committerScott Wheeler <wheeler@kde.org>
Sun, 1 Apr 2007 22:08:44 +0000 (22:08 +0000)
Simplified version of the patch from Xavier Duret.

BUG:141680

git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@649032 283d02a7-25f6-0310-bc7c-ecb5cbfe19da

taglib/mpeg/id3v2/frames/textidentificationframe.cpp

index 14e966226309d645ad7c5aeeb49c8836aee14ec2..a74488f8e9096f8ad2067e42690b08d53b8dc6a6 100644 (file)
@@ -108,7 +108,17 @@ void TextIdentificationFrame::parseFields(const ByteVector &data)
 
   int byteAlign = d->textEncoding == String::Latin1 || d->textEncoding == String::UTF8 ? 1 : 2;
 
-  ByteVectorList l = ByteVectorList::split(data.mid(1), textDelimiter(d->textEncoding), byteAlign);
+       // build a small counter to strip nulls off the end of the field
+
+  int dataLength = data.size() - 1;
+
+  while(dataLength > 0 && data[dataLength] == 0)
+    dataLength--;
+
+  while(dataLength % byteAlign != 0)
+    dataLength++;
+
+  ByteVectorList l = ByteVectorList::split(data.mid(1, dataLength), textDelimiter(d->textEncoding), byteAlign);
 
   d->fieldList.clear();