ID3v2: Don't allow empty strings in Accessor::set_*

This commit is contained in:
Serial 2022-07-21 16:15:43 -04:00
parent 079885eefe
commit 8d8158e105
No known key found for this signature in database
GPG key ID: DA95198DC17C4568
2 changed files with 20 additions and 11 deletions

View file

@ -12,7 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **ItemKey**: `ItemKey::{REPLAYGAIN_ALBUM_GAIN, REPLAYGAIN_ALBUM_PEAK, REPLAYGAIN_TRACK_GAIN, REPLAYGAIN_TRACK_PEAK}`
### Changed
- **ID3v2**: `TXXX`/`WXXX` frames will be stored by their descriptions in `ID3v2Tag` -> `Tag` conversions
- **ID3v2**:
- `TXXX`/`WXXX` frames will be stored by their descriptions in `ID3v2Tag` -> `Tag` conversions
- Stopped allowing empty strings in `Accessor::set_*`
### Fixed
- **Tag**: The `Accessor::set_*` methods will stop falling through, and adding empty strings

View file

@ -36,6 +36,11 @@ macro_rules! impl_accessor {
}
fn [<set_ $name>](&mut self, value: String) {
if value.is_empty() {
self.remove($id);
return;
}
self.insert(Frame {
id: FrameID::Valid(String::from($id)),
value: FrameValue::Text {
@ -395,16 +400,18 @@ impl Accessor for ID3v2Tag {
return;
}
self.insert(Frame {
id: FrameID::Valid(String::from("COMM")),
value: FrameValue::Comment(LanguageFrame {
encoding: TextEncoding::UTF8,
language: String::from("eng"),
description: String::new(),
content: value,
}),
flags: FrameFlags::default(),
});
if !value.is_empty() {
self.insert(Frame {
id: FrameID::Valid(String::from("COMM")),
value: FrameValue::Comment(LanguageFrame {
encoding: TextEncoding::UTF8,
language: String::from("eng"),
description: String::new(),
content: value,
}),
flags: FrameFlags::default(),
});
}
}
fn remove_comment(&mut self) {