Fix treating short and long ID3v2 frame IDs as equal

This commit is contained in:
Martchus 2018-05-31 00:25:06 +02:00
parent 047e9f7fd0
commit a3bf8267ac
1 changed files with 12 additions and 4 deletions

View File

@ -394,17 +394,25 @@ void Id3v2Tag::setVersion(byte majorVersion, byte revisionVersion)
/*! /*!
* \brief Returns true if \a lhs goes before \a rhs; otherwise returns false. * \brief Returns true if \a lhs goes before \a rhs; otherwise returns false.
* \todo Don't pass args by reference in v8.
*/ */
bool FrameComparer::operator()(const uint32 &lhs, const uint32 &rhs) const bool FrameComparer::operator()(const uint32 &lhsRef, const uint32 &rhsRef) const
{ {
uint32 lhs(lhsRef);
uint32 rhs(rhsRef);
if (lhs == rhs) { if (lhs == rhs) {
return false; return false;
} }
const bool lhsLong = Id3v2FrameIds::isLongId(lhs); const bool lhsLong = Id3v2FrameIds::isLongId(lhs);
const bool rhsLong = Id3v2FrameIds::isLongId(rhs); const bool rhsLong = Id3v2FrameIds::isLongId(rhs);
if (((lhsLong && !rhsLong) && (lhs == Id3v2FrameIds::convertToLongId(rhs))) if (lhsLong != rhsLong) {
|| ((!lhsLong && rhsLong) && (Id3v2FrameIds::convertToLongId(lhs) == rhs))) { if (!lhsLong) {
return false; lhs = Id3v2FrameIds::convertToLongId(lhs);
} else if (!rhsLong) {
rhs = Id3v2FrameIds::convertToLongId(rhs);
}
} }
if (lhs == Id3v2FrameIds::lUniqueFileId || lhs == Id3v2FrameIds::sUniqueFileId) { if (lhs == Id3v2FrameIds::lUniqueFileId || lhs == Id3v2FrameIds::sUniqueFileId) {