Skip to content

Panic reading mp3 tag #492

Closed
Closed
@milesegan

Description

@milesegan

Reproducer

I tried this code:

use std::path::Path;

use lofty::config::{ParseOptions, ParsingMode};
use lofty::file::{AudioFile, TaggedFileExt};
use lofty::probe::Probe;
use lofty::tag::Accessor;

fn main() {
    // the error seems to occur with strict or relaxed parsing mode
    let parsing_options = ParseOptions::new().parsing_mode(ParsingMode::Relaxed);
    let path = Path::new("sample.mp3");
    let file = Probe::open(&path)
        .expect("can't probe")
        .options(parsing_options)
        .read()
        .expect("can't read");
    let tag = file.primary_tag().expect("no tag");
    let properties = file.properties();
    println!("{:?}", tag.artist());
    println!("{:?}", tag.year());
}

Summary

This results in this panic:

thread 'main' panicked at src/main.rs:16:10:
can't read: TextDecode("UTF-16 string has an odd length")

Expected behavior

ffprobe and id3info both seem to be able to read this sample file ok. Are they just falling back to some kind of best-effort conversion for badly encoded UTF-16 strings perhaps?

Assets

sample.mp3.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions