AIFF: Add zero-sized text chunks test

This commit is contained in:
Serial 2022-06-29 22:56:24 -04:00
parent 8e9ab4b1ad
commit f4ed05ed55
No known key found for this signature in database
GPG key ID: DA95198DC17C4568
4 changed files with 21 additions and 1 deletions

View file

@ -79,6 +79,10 @@ where
// so there's no need to replace anything we already read
#[cfg(feature = "aiff_text_chunks")]
b"COMT" if comments.is_empty() => {
if chunks.size < 2 {
continue;
}
let num_comments = data.read_u16::<BigEndian>()?;
for _ in 0..num_comments {

View file

@ -539,4 +539,21 @@ mod tests {
);
assert!(aiff_text.comments.is_none());
}
#[test]
fn zero_sized_text_chunks() {
let tag_bytes =
crate::tag::utils::test_utils::read_path("tests/tags/assets/zero.aiff_text");
let aiff_text = super::super::read::read_from(&mut Cursor::new(tag_bytes), false)
.unwrap()
.text_chunks
.unwrap();
assert_eq!(aiff_text.name, Some(String::new()));
assert_eq!(aiff_text.author, Some(String::new()));
assert_eq!(aiff_text.annotations, Some(vec![String::new()]));
assert_eq!(aiff_text.comments, None); // Comments have additional information we need, so we ignore on empty
assert_eq!(aiff_text.copyright, Some(String::new()));
}
}

View file

@ -9,7 +9,6 @@ use lofty::AudioFile;
// TODO: zero-size vorbis comments
// TODO: zero-size APE tag
// TODO: zero-size ilst
// TODO: zero-size AIFF text chunks
fn read_file<A: AudioFile>(path: &str) -> bool {
let res = <A as AudioFile>::read_from(&mut std::fs::File::open(path).unwrap(), true);

Binary file not shown.