9 Commits

Author SHA1 Message Date
Lukáš Lalinský
8792f8df82 Final changes
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1115755 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
2010-04-17 11:31:35 +00:00
Lukáš Lalinský
9dcdecc810 Fix parsing of regular 32-bit integers in SynchData::toUInt()
BUG:231075


git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1115275 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
2010-04-15 20:22:21 +00:00
Lukáš Lalinský
f6478a4172 Add a BIC comment about merging String::toInt
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1114105 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
2010-04-12 18:53:27 +00:00
Lukáš Lalinský
91f94f593b Info about the new toInt method
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1114094 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
2010-04-12 18:41:10 +00:00
Lukáš Lalinský
10e4350410 Updated NEWS
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1114093 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
2010-04-12 18:35:41 +00:00
Lukáš Lalinský
414a49cc16 Include taglib_config.h by default
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1114090 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
2010-04-12 18:32:04 +00:00
Lukáš Lalinský
19b2341411 Fix upgrading of ID3v2.3 genre with number 0 (Blues)
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1114089 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
2010-04-12 18:27:59 +00:00
Lukáš Lalinský
d5eb51e452 Update all version numbers to 1.6.3
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1114073 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
2010-04-12 17:43:03 +00:00
Scott Wheeler
2811d24efa Update to current automake
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1113098 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
2010-04-09 22:51:26 +00:00
23 changed files with 124 additions and 41 deletions

View File

@@ -40,7 +40,7 @@ endif (WIN32)
SET(TAGLIB_LIB_MAJOR_VERSION "1")
SET(TAGLIB_LIB_MINOR_VERSION "6")
SET(TAGLIB_LIB_PATCH_VERSION "1")
SET(TAGLIB_LIB_PATCH_VERSION "3")
SET(TAGLIB_LIB_VERSION_STRING "${TAGLIB_LIB_MAJOR_VERSION}.${TAGLIB_LIB_MINOR_VERSION}.${TAGLIB_LIB_PATCH_VERSION}")

View File

@@ -38,7 +38,7 @@ apidox:
fi; \
cp $(top_srcdir)/admin/Doxyfile.global taglib.doxyfile; \
echo "PROJECT_NAME = TagLib" >> taglib.doxyfile; \
echo "PROJECT_NUMBER = \"Version 1.6.2\"" >> taglib.doxyfile; \
echo "PROJECT_NUMBER = \"Version 1.6.3\"" >> taglib.doxyfile; \
echo "INPUT = $(srcdir)" >> taglib.doxyfile; \
echo "OUTPUT_DIRECTORY = doc/api" >> taglib.doxyfile; \
echo "HTML_OUTPUT = html" >> taglib.doxyfile; \

10
NEWS
View File

@@ -1,3 +1,13 @@
TagLib 1.6.3 (Apr 17, 2010)
===========================
* Fixed definitions of the TAGLIB_WITH_MP4 and TAGLIB_WITH_ASF macros.
* Fixed upgrading of ID3v2.3 genre frame with ID3v1 code 0 (Blues).
* New method `int String::toInt(bool *ok)` which can return whether the
conversion to a number was successfull.
* Fixed parsing of incorrectly written lengths in ID3v2 (affects mainly
compressed frames). (BUG:231075)
TagLib 1.6.2 (Apr 9, 2010)
==========================

View File

@@ -68,7 +68,7 @@ case $AUTOMAKE_STRING in
echo "*** KDE requires automake $required_automake_version"
exit 1
;;
automake*1.6.* | automake*1.7* | automake*1.8* | automake*1.9* | automake*1.10*)
automake*1.6.* | automake*1.7* | automake*1.8* | automake*1.9* | automake*1.10* | automake*1.11*)
echo "*** $AUTOMAKE_STRING found."
UNSERMAKE=no
;;

View File

@@ -6,6 +6,6 @@ includedir=@includedir@
Name: TagLib C Bindings
Description: Audio meta-data library (C bindings)
Requires: taglib
Version: 1.6.2
Version: 1.6.3
Libs: -L${libdir} -ltag_c
Cflags: -I${includedir}/taglib

View File

@@ -38,7 +38,7 @@ dnl Perform program name transformation
AC_ARG_PROGRAM
dnl Automake doc recommends to do this only here. (Janos)
AM_INIT_AUTOMAKE(taglib,1.6.2)
AM_INIT_AUTOMAKE(taglib,1.6.3)
dnl almost the same like KDE_SET_PEFIX but the path is /usr/local
dnl

View File

@@ -17,7 +17,7 @@
<td>
<div id="intro">
<table border="0" height="119" cellpadding="0" cellspacing="0" width="100%">
<tr><td valign="top"><h1>TagLib 1.6.2 ($title)</h1></td></tr>
<tr><td valign="top"><h1>TagLib 1.6.3 ($title)</h1></td></tr>
<tr>
<td valign="bottom">
<div id="links">

View File

@@ -35,7 +35,7 @@ do
flags="$flags -I$includedir/taglib"
;;
--version)
echo 1.6.2
echo 1.6.3
;;
--prefix)
echo $prefix

View File

@@ -35,7 +35,7 @@ do
flags="$flags -I$includedir/taglib"
;;
--version)
echo 1.6.2
echo 1.6.3
;;
--prefix)
echo $prefix

View File

@@ -6,6 +6,6 @@ includedir=@includedir@
Name: TagLib
Description: Audio meta-data library
Requires:
Version: 1.6
Version: 1.6.3
Libs: -L${libdir} -ltag
Cflags: -I${includedir}/taglib

View File

@@ -47,8 +47,9 @@ taglib_includedir = $(includedir)/taglib
# 7:1:6 -- TagLib 1.6
# 8:0:7 -- TagLib 1.6.1
# 9:0:8 -- TagLib 1.6.2
# 10:0:9 -- TagLib 1.6.3
libtag_la_LDFLAGS = $(all_libraries) -no-undefined -version-info 9:0:8
libtag_la_LDFLAGS = $(all_libraries) -no-undefined -version-info 10:0:9
libtag_la_LIBADD = ./mpeg/libmpeg.la ./ogg/libogg.la ./flac/libflac.la ./mpc/libmpc.la \
./ape/libape.la ./toolkit/libtoolkit.la ./wavpack/libwavpack.la \
./trueaudio/libtrueaudio.la ./riff/libriff.la \

View File

@@ -412,10 +412,11 @@ void FrameFactory::updateGenre(TextIdentificationFrame *frame) const
if(s.startsWith("(") && end > 0) {
// "(12)Genre"
String text = s.substr(end + 1);
int number = s.substr(1, end - 1).toInt();
if (number > 0 && number <= 255 && !(ID3v1::genre(number) == text))
bool ok;
int number = s.substr(1, end - 1).toInt(&ok);
if(ok && number >= 0 && number <= 255 && !(ID3v1::genre(number) == text))
newfields.append(s.substr(1, end - 1));
if (!text.isEmpty())
if(!text.isEmpty())
newfields.append(text);
}
else {

View File

@@ -46,14 +46,10 @@ TagLib::uint SynchData::toUInt(const ByteVector &data)
}
if(notSynchSafe) {
/*
* Invalid data; assume this was created by some buggy software that just
* put normal integers here rather than syncsafe ones, and try it that
* way.
*/
sum = 0;
for(int i = 0; i <= last; i++)
sum |= data[i] << ((last - i) * 8);
// Invalid data; assume this was created by some buggy software that just
// put normal integers here rather than syncsafe ones, and try it that
// way.
sum = (data.size() > 4) ? data.mid(0, 4).toUInt() : data.toUInt();
}
return sum;

View File

@@ -164,19 +164,10 @@ String ID3v2::Tag::genre() const
if((*it).isEmpty())
continue;
bool isNumber = true;
for(String::ConstIterator charIt = (*it).begin();
isNumber && charIt != (*it).end();
++charIt)
{
isNumber = *charIt >= '0' && *charIt <= '9';
}
if(isNumber) {
int number = (*it).toInt();
if(number >= 0 && number <= 255)
*it = ID3v1::genre(number);
bool ok;
int number = (*it).toInt(&ok);
if(ok && number >= 0 && number <= 255) {
*it = ID3v1::genre(number);
}
if(std::find(genres.begin(), genres.end(), *it) == genres.end())

View File

@@ -6,10 +6,10 @@ TEMPLATE = lib
CONFIG += lib_bundle staticlib
CONFIG += x86 x86_64 ppc
CONFIG -= qt
DEFINES += HAVE_ZLIB=1 NDEBUG WITH_ASF WITH_MP4
DEFINES += HAVE_ZLIB=1 NDEBUG WITH_ASF WITH_MP4 TAGLIB_NO_CONFIG
LIBS += -lz
TARGET = TagLib
VERSION = 1.6.2
VERSION = 1.6.3
DEPENDPATH += . \
ape \
asf \

View File

@@ -38,7 +38,7 @@
#define TAGLIB_EXPORT
#endif
#ifdef HAVE_CONFIG_H
#ifndef TAGLIB_NO_CONFIG
#include "taglib_config.h"
#endif

View File

@@ -28,7 +28,7 @@
#define TAGLIB_MAJOR_VERSION 1
#define TAGLIB_MINOR_VERSION 6
#define TAGLIB_PATCH_VERSION 0
#define TAGLIB_PATCH_VERSION 3
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 1))
#define TAGLIB_IGNORE_MISSING_DESTRUCTOR _Pragma("GCC diagnostic ignored \"-Wnon-virtual-dtor\"")

View File

@@ -431,18 +431,28 @@ ByteVector String::data(Type t) const
}
int String::toInt() const
{
return toInt(0);
}
int String::toInt(bool *ok) const
{
int value = 0;
bool negative = d->data[0] == '-';
uint i = negative ? 1 : 0;
uint size = d->data.size();
bool negative = size > 0 && d->data[0] == '-';
uint start = negative ? 1 : 0;
uint i = start;
for(; i < d->data.size() && d->data[i] >= '0' && d->data[i] <= '9'; i++)
for(; i < size && d->data[i] >= '0' && d->data[i] <= '9'; i++)
value = value * 10 + (d->data[i] - '0');
if(negative)
value = value * -1;
if(ok)
*ok = (size > start && i == size);
return value;
}

View File

@@ -291,9 +291,22 @@ namespace TagLib {
/*!
* Convert the string to an integer.
*
* Returns the integer if the conversion was successfull or 0 if the
* string does not represent a number.
*/
// BIC: merge with the method below
int toInt() const;
/*!
* Convert the string to an integer.
*
* If the conversion was successfull, it sets the value of \a *ok to
* true and returns the integer. Otherwise it sets \a *ok to false
* and the result is undefined.
*/
int toInt(bool *ok) const;
/*!
* Returns a string with the leading and trailing whitespace stripped.
*/

Binary file not shown.

View File

@@ -61,6 +61,7 @@ class TestID3v2 : public CppUnit::TestFixture
CPPUNIT_TEST(testUpdateGenre24);
CPPUNIT_TEST(testUpdateDate22);
// CPPUNIT_TEST(testUpdateFullDate22); TODO TYE+TDA should be upgraded to TDRC together
CPPUNIT_TEST(testCompressedFrameWithBrokenLength);
CPPUNIT_TEST_SUITE_END();
public:
@@ -455,6 +456,19 @@ public:
CPPUNIT_ASSERT_EQUAL(String("2010-04-03"), f.ID3v2Tag()->frameListMap()["TDRC"].front()->toString());
}
void testCompressedFrameWithBrokenLength()
{
MPEG::File f("data/compressed_id3_frame.mp3", false);
CPPUNIT_ASSERT(f.ID3v2Tag()->frameListMap().contains("APIC"));
ID3v2::AttachedPictureFrame *frame =
static_cast<TagLib::ID3v2::AttachedPictureFrame*>(f.ID3v2Tag()->frameListMap()["APIC"].front());
CPPUNIT_ASSERT(frame);
CPPUNIT_ASSERT_EQUAL(String("image/bmp"), frame->mimeType());
CPPUNIT_ASSERT_EQUAL(ID3v2::AttachedPictureFrame::Other, frame->type());
CPPUNIT_ASSERT_EQUAL(String(""), frame->description());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(86414), frame->picture().size());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2);

View File

@@ -40,6 +40,7 @@ class TestString : public CppUnit::TestFixture
CPPUNIT_TEST(testUTF16DecodeEmptyWithBOM);
CPPUNIT_TEST(testAppendCharDetach);
CPPUNIT_TEST(testAppendStringDetach);
CPPUNIT_TEST(testToInt);
CPPUNIT_TEST_SUITE_END();
public:
@@ -165,6 +166,33 @@ public:
CPPUNIT_ASSERT_EQUAL(3, String("foo.bar").rfind("."));
}
void testToInt()
{
bool ok;
CPPUNIT_ASSERT_EQUAL(String("123").toInt(&ok), 123);
CPPUNIT_ASSERT_EQUAL(ok, true);
CPPUNIT_ASSERT_EQUAL(String("-123").toInt(&ok), -123);
CPPUNIT_ASSERT_EQUAL(ok, true);
CPPUNIT_ASSERT_EQUAL(String("abc").toInt(&ok), 0);
CPPUNIT_ASSERT_EQUAL(ok, false);
CPPUNIT_ASSERT_EQUAL(String("1x").toInt(&ok), 1);
CPPUNIT_ASSERT_EQUAL(ok, false);
CPPUNIT_ASSERT_EQUAL(String("").toInt(&ok), 0);
CPPUNIT_ASSERT_EQUAL(ok, false);
CPPUNIT_ASSERT_EQUAL(String("-").toInt(&ok), 0);
CPPUNIT_ASSERT_EQUAL(ok, false);
CPPUNIT_ASSERT_EQUAL(String("123").toInt(), 123);
CPPUNIT_ASSERT_EQUAL(String("-123").toInt(), -123);
CPPUNIT_ASSERT_EQUAL(String("123aa").toInt(), 123);
CPPUNIT_ASSERT_EQUAL(String("-123aa").toInt(), -123);
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestString);

View File

@@ -34,6 +34,8 @@ class TestID3v2SynchData : public CppUnit::TestFixture
CPPUNIT_TEST(test1);
CPPUNIT_TEST(test2);
CPPUNIT_TEST(test3);
CPPUNIT_TEST(testToUIntBroken);
CPPUNIT_TEST(testToUIntBrokenAndTooLarge);
CPPUNIT_TEST(testDecode1);
CPPUNIT_TEST(testDecode2);
CPPUNIT_TEST_SUITE_END();
@@ -67,6 +69,23 @@ public:
CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::fromUInt(129), v);
}
void testToUIntBroken()
{
char data[] = { 0, 0, 0, -1 };
char data2[] = { 0, 0, -1, -1 };
CPPUNIT_ASSERT_EQUAL(TagLib::uint(255), ID3v2::SynchData::toUInt(ByteVector(data, 4)));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(65535), ID3v2::SynchData::toUInt(ByteVector(data2, 4)));
}
void testToUIntBrokenAndTooLarge()
{
char data[] = { 0, 0, 0, -1, 0 };
ByteVector v(data, 5);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(255), ID3v2::SynchData::toUInt(v));
}
void testDecode1()
{
ByteVector a("\xff\x00\x00", 3);