Description: Optionally emit a notice for unsupported ID3v2 tag versions. id3lib only fully supports ID3v2.3.0 and earlier (ID3V2_LATEST). When the tag header reports a higher or unrecognised v2 version (e.g. ID3v2.4), the tag cannot be parsed correctly and is discarded without any indication, so a caller cannot tell an unsupported tag from a missing one. . A shared library must not write to stderr unsolicited, and ID3v2.4 tags are very common in the wild, so the notice is made opt-in: it is printed only when the ID3LIB_WARN_UNSUPPORTED environment variable is set. By default the library stays completely silent, preserving the previous behaviour for all existing callers. . This does NOT add ID3v2.4 parsing and does not change any parsing behaviour; it only makes the unsupported-version situation observable on demand. Related to Debian bug #449186, which is intentionally kept open: full ID3v2.4 support is out of scope for this change. Author: Martin A. Godisch Bug-Debian: https://bugs.debian.org/449186 Forwarded: not-needed Last-Update: 2026-06-20 --- --- a/src/header_tag.cpp +++ b/src/header_tag.cpp @@ -31,6 +31,7 @@ #include "tag.h" #include "io_helpers.h" #include "spec.h" +#include // for std::getenv (opt-in diagnostic below) using namespace dami; @@ -114,6 +115,22 @@ uchar minor = reader.readChar(); this->SetSpec(ID3_VerRevToV2Spec(major, minor)); + // id3lib only fully supports up to ID3v2.3.0 (ID3V2_LATEST). A higher or + // unrecognised v2 version (e.g. ID3v2.4) cannot be parsed correctly and is + // dropped without any indication (Debian bug #449186). When the + // ID3LIB_WARN_UNSUPPORTED environment variable is set, emit a single notice + // so this case can be made observable. The library stays silent by default + // (a shared library must not write to stderr unsolicited, and ID3v2.4 tags + // are common). Parsing behaviour is unchanged either way. + if ((this->GetSpec() == ID3V2_UNKNOWN || this->GetSpec() > ID3V2_LATEST) && + std::getenv("ID3LIB_WARN_UNSUPPORTED") != NULL) + { + std::clog << "id3lib: ID3v2." << static_cast(major) << "." + << static_cast(minor) + << " tag found, but only ID3v2.3.0 and earlier are supported; " + << "this tag may not be read correctly" << std::endl; + } + // Get the flags at the appropriate offset _flags.set(static_cast(reader.readChar()));