mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 13:10:26 -04:00
Remove null byte removal for table of contents frame
This commit is contained in:
parent
8b564baf01
commit
8bb8fc5fe6
@ -50,30 +50,6 @@ public:
|
||||
FrameList embeddedFrameList;
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
// These functions are needed to try to aim for backward compatibility with
|
||||
// an API that previously (unreasonably) required null bytes to be appended
|
||||
// at the end of identifiers explicitly by the API user.
|
||||
|
||||
// BIC: remove these
|
||||
|
||||
ByteVector &strip(ByteVector &b)
|
||||
{
|
||||
if(b.endsWith('\0'))
|
||||
b.resize(b.size() - 1);
|
||||
return b;
|
||||
}
|
||||
|
||||
ByteVectorList &strip(ByteVectorList &l)
|
||||
{
|
||||
for(auto &v : l) {
|
||||
strip(v);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public methods
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -93,7 +69,6 @@ TableOfContentsFrame::TableOfContentsFrame(const ByteVector &elementID,
|
||||
d(std::make_unique<TableOfContentsFramePrivate>())
|
||||
{
|
||||
d->elementID = elementID;
|
||||
strip(d->elementID);
|
||||
d->childElements = children;
|
||||
|
||||
for(const auto &frame : embeddedFrames)
|
||||
@ -130,7 +105,6 @@ ByteVectorList TableOfContentsFrame::childElements() const
|
||||
void TableOfContentsFrame::setElementID(const ByteVector &eID)
|
||||
{
|
||||
d->elementID = eID;
|
||||
strip(d->elementID);
|
||||
}
|
||||
|
||||
void TableOfContentsFrame::setIsTopLevel(const bool &t)
|
||||
@ -146,13 +120,11 @@ void TableOfContentsFrame::setIsOrdered(const bool &o)
|
||||
void TableOfContentsFrame::setChildElements(const ByteVectorList &l)
|
||||
{
|
||||
d->childElements = l;
|
||||
strip(d->childElements);
|
||||
}
|
||||
|
||||
void TableOfContentsFrame::addChildElement(const ByteVector &cE)
|
||||
{
|
||||
d->childElements.append(cE);
|
||||
strip(d->childElements);
|
||||
}
|
||||
|
||||
void TableOfContentsFrame::removeChildElement(const ByteVector &cE)
|
||||
|
@ -70,8 +70,8 @@ namespace TagLib {
|
||||
TableOfContentsFrame &operator=(const TableOfContentsFrame &) = delete;
|
||||
|
||||
/*!
|
||||
* Returns the elementID of the frame. Element ID
|
||||
* is a null terminated string, however it's not human-readable.
|
||||
* Returns the elementID of the frame.
|
||||
* Element ID is not intended to be human readable.
|
||||
*
|
||||
* \see setElementID()
|
||||
*/
|
||||
@ -109,8 +109,7 @@ namespace TagLib {
|
||||
ByteVectorList childElements() const;
|
||||
|
||||
/*!
|
||||
* Sets the elementID of the frame to \a eID. If \a eID isn't
|
||||
* null terminated, a null char is appended automatically.
|
||||
* Sets the elementID of the frame to \a eID.
|
||||
*
|
||||
* \see elementID()
|
||||
*/
|
||||
|
@ -1533,11 +1533,11 @@ public:
|
||||
{
|
||||
ID3v2::Header header;
|
||||
ID3v2::TableOfContentsFrame f(&header, "CTOC");
|
||||
f.setElementID(ByteVector("\x54\x00", 2));
|
||||
f.setElementID("T");
|
||||
f.setIsTopLevel(false);
|
||||
f.setIsOrdered(true);
|
||||
f.addChildElement(ByteVector("\x43\x00", 2));
|
||||
f.addChildElement(ByteVector("\x44\x00", 2));
|
||||
f.addChildElement("C");
|
||||
f.addChildElement("D");
|
||||
auto eF = new ID3v2::TextIdentificationFrame("TIT2");
|
||||
eF->setText("TC1");
|
||||
f.addEmbeddedFrame(eF);
|
||||
|
Loading…
Reference in New Issue
Block a user