mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-09-20 06:11:57 +00:00
Tag: Add missing return
This commit is contained in:
parent
5d6801b0db
commit
903531e07f
2 changed files with 16 additions and 1 deletions
|
@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
- **Tag**: The `Accessor::set_*` methods will stop falling through, and adding empty strings
|
||||
|
||||
## [0.7.2] - 2022-07-13
|
||||
|
||||
This release mostly addresses issues uncovered by fuzzing, thanks to [@5225225](https://github.com/5225225)!
|
||||
|
|
|
@ -28,6 +28,7 @@ macro_rules! impl_accessor {
|
|||
fn [<set_ $name>](&mut self, value: String) {
|
||||
if value.is_empty() {
|
||||
self.[<remove_ $name>]();
|
||||
return;
|
||||
}
|
||||
|
||||
self.insert_item(TagItem::new(ItemKey::$item_key, ItemValue::Text(value)));
|
||||
|
@ -632,7 +633,7 @@ impl TagType {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::tag::utils::test_utils::read_path;
|
||||
use crate::{Picture, PictureType, Tag, TagExt, TagType};
|
||||
use crate::{Accessor, Picture, PictureType, Tag, TagExt, TagType};
|
||||
use std::io::{Seek, Write};
|
||||
use std::process::Command;
|
||||
|
||||
|
@ -666,4 +667,15 @@ mod tests {
|
|||
!stderr.contains("Header processing failed: Invalid data found when processing input")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insert_empty() {
|
||||
let mut tag = Tag::new(TagType::ID3v2);
|
||||
tag.set_title(String::from("Foo title"));
|
||||
|
||||
assert_eq!(tag.title(), Some("Foo title"));
|
||||
|
||||
tag.set_title(String::new());
|
||||
assert_eq!(tag.title(), None);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue