From 9d09f9b413639351c407d29183e2fc1d8b9b6ed7 Mon Sep 17 00:00:00 2001 From: Ryan Francesconi <2917795+ryanfrancesconi@users.noreply.github.com> Date: Wed, 28 Oct 2026 09:12:02 -0700 Subject: [PATCH] RIFF: Report unknown INFO fields by their ID in properties() (#1471) RIFF::Info::Tag::properties() passed the result of the failed property key lookup, an empty string, to addUnsupportedData() instead of the field ID. An INFO chunk with a field that has no property mapping therefore reported an empty entry in unsupportedData(), and passing that list to removeUnsupportedProperties(), which erases by ID, removed nothing. Report the field ID instead, decoded as Latin-1 to match how removeUnsupportedProperties() encodes it. The new test sets a mapped field (INAM) and an unmapped one (ITRK), checks that unsupportedData() is ["ITRK"], and that removeUnsupportedProperties() with that list removes ITRK and keeps INAM. --- taglib/riff/wav/infotag.cpp | 2 +- tests/test_info.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/taglib/riff/wav/infotag.cpp b/taglib/riff/wav/infotag.cpp index d76bf769..6c43e1fc 100644 --- a/taglib/riff/wav/infotag.cpp +++ b/taglib/riff/wav/infotag.cpp @@ -204,7 +204,7 @@ PropertyMap RIFF::Info::Tag::properties() const props[key].append(val); } else { - props.addUnsupportedData(key); + props.addUnsupportedData(String(id, String::Latin1)); } } return props; diff --git a/tests/test_info.cpp b/tests/test_info.cpp index c5b91f97..c481c49e 100644 --- a/tests/test_info.cpp +++ b/tests/test_info.cpp @@ -27,6 +27,7 @@ #include #include "infotag.h" +#include "tpropertymap.h" #include #include "utils.h" @@ -38,6 +39,7 @@ class TestInfoTag : public CppUnit::TestFixture CPPUNIT_TEST_SUITE(TestInfoTag); CPPUNIT_TEST(testTitle); CPPUNIT_TEST(testNumericFields); + CPPUNIT_TEST(testUnsupportedProperties); CPPUNIT_TEST_SUITE_END(); public: @@ -70,6 +72,21 @@ public: CPPUNIT_ASSERT_EQUAL(static_cast(1234), tag.year()); CPPUNIT_ASSERT_EQUAL(String("1234"), tag.fieldText("ICRD")); } + + void testUnsupportedProperties() + { + RIFF::Info::Tag tag; + tag.setFieldText("INAM", "Title"); + tag.setFieldText("ITRK", "7"); + + const PropertyMap props = tag.properties(); + CPPUNIT_ASSERT_EQUAL(StringList("ITRK"), props.unsupportedData()); + CPPUNIT_ASSERT_EQUAL(StringList("Title"), props["TITLE"]); + + tag.removeUnsupportedProperties(props.unsupportedData()); + CPPUNIT_ASSERT(!tag.fieldListMap().contains("ITRK")); + CPPUNIT_ASSERT_EQUAL(String("Title"), tag.fieldText("INAM")); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(TestInfoTag);