Skip to content

VorbisComments: TRACKNUMBER=current/total handling should be under implicit conversions #540

@Serial-ATA

Description

@Serial-ATA

The special case for TRACKNUMBER in VorbisComments is an implicit conversion, and it can alter metadata even if it isn't in the current/total form:

// Support the case of TRACKNUMBER being equal to current/total
k if k.eq_ignore_ascii_case(b"TRACKNUMBER") => {
match utf8_decode_str(value) {
Ok(value) => {
// try to parse as current/total
let mut value_split = value.splitn(2, '/');
let track_number: Option<u32> =
value_split.next().and_then(|b| b.parse().ok());
let track_total: Option<u32> =
value_split.next().and_then(|b| b.parse().ok());
if let Some(n) = track_number {
tag.set_track(n);
} else {
// Probably some other format, like a vinyl track number (A1, B1, etc.).
// Just leave it up to the caller to deal with.
tag.items
.push((String::from("TRACKNUMBER"), value.to_owned()));
}
if let Some(n) = track_total {
tag.set_track_total(n);
}
},
Err(e) => {
if parse_mode == ParsingMode::Strict {
return Err(e);
}
log::warn!("Non UTF-8 value found, discarding field {key:?}");
continue;
},
}
},

Should be skipped if ParseOptions::implicit_conversions is disabled.

Discussed in #539

Originally posted by Methapon2001 August 14, 2025
When I try to get track number and track total, disc and disc total from my FLAC (or other file type) file which should have leading 0, instead I got number with non leading using get or get_string.

I tried with wav file it works as expected.

I tried change probed options(disable implicit conversion / relaxed) and it is not working.

I wonder if this is bug or working as expected.

I tried symphonia it does contains zero leading and also in MusicBrainz Picard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions