From 874d495b29f1a238679a167fc0eaba466d9c80c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= Date: Mon, 1 Nov 2010 16:32:37 +0000 Subject: [PATCH] Accept both "ID3 " and "id3 " as valid ID3 chunk IDs in RIFF files Patch by Stephen F. Booth git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1191982 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- taglib/riff/aiff/aifffile.cpp | 10 +++++++--- taglib/riff/wav/wavfile.cpp | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/taglib/riff/aiff/aifffile.cpp b/taglib/riff/aiff/aifffile.cpp index 9bc5cd18..70040e8e 100644 --- a/taglib/riff/aiff/aifffile.cpp +++ b/taglib/riff/aiff/aifffile.cpp @@ -36,7 +36,8 @@ class RIFF::AIFF::File::FilePrivate public: FilePrivate() : properties(0), - tag(0) + tag(0), + tagChunkID("ID3 ") { } @@ -49,6 +50,7 @@ public: Properties *properties; ID3v2::Tag *tag; + ByteVector tagChunkID; }; //////////////////////////////////////////////////////////////////////////////// @@ -85,7 +87,7 @@ bool RIFF::AIFF::File::save() return false; } - setChunkData("ID3 ", d->tag->render()); + setChunkData(d->tagChunkID, d->tag->render()); return true; } @@ -97,8 +99,10 @@ bool RIFF::AIFF::File::save() void RIFF::AIFF::File::read(bool readProperties, Properties::ReadStyle propertiesStyle) { for(uint i = 0; i < chunkCount(); i++) { - if(chunkName(i) == "ID3 ") + if(chunkName(i) == "ID3 " || chunkName(i) == "id3 ") { + d->tagChunkID = chunkName(i); d->tag = new ID3v2::Tag(this, chunkOffset(i)); + } else if(chunkName(i) == "COMM" && readProperties) d->properties = new Properties(chunkData(i), propertiesStyle); } diff --git a/taglib/riff/wav/wavfile.cpp b/taglib/riff/wav/wavfile.cpp index f323a27d..c4e62fa3 100644 --- a/taglib/riff/wav/wavfile.cpp +++ b/taglib/riff/wav/wavfile.cpp @@ -36,7 +36,8 @@ class RIFF::WAV::File::FilePrivate public: FilePrivate() : properties(0), - tag(0) + tag(0), + tagChunkID("ID3 ") { } @@ -49,6 +50,7 @@ public: Properties *properties; ID3v2::Tag *tag; + ByteVector tagChunkID; }; //////////////////////////////////////////////////////////////////////////////// @@ -85,7 +87,7 @@ bool RIFF::WAV::File::save() return false; } - setChunkData("ID3 ", d->tag->render()); + setChunkData(d->tagChunkID, d->tag->render()); return true; } @@ -99,8 +101,10 @@ void RIFF::WAV::File::read(bool readProperties, Properties::ReadStyle properties ByteVector formatData; uint streamLength = 0; for(uint i = 0; i < chunkCount(); i++) { - if(chunkName(i) == "ID3 ") + if(chunkName(i) == "ID3 " || chunkName(i) == "id3 ") { + d->tagChunkID = chunkName(i); d->tag = new ID3v2::Tag(this, chunkOffset(i)); + } else if(chunkName(i) == "fmt " && readProperties) formatData = chunkData(i); else if(chunkName(i) == "data" && readProperties)