mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-11-10 06:34:18 +00:00
ID3v2: Don't allow empty strings in Accessor::set_*
This commit is contained in:
parent
079885eefe
commit
8d8158e105
2 changed files with 20 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue