77
77
len -= u64:: from ( comment_len) ;
78
78
79
79
// KEY=VALUE
80
- let mut comment_split = comment_bytes. splitn ( 2 , b'=' ) ;
80
+ let mut comment_split = comment_bytes. splitn ( 2 , |b| * b == b'=' ) ;
81
81
82
82
let key = match comment_split. next ( ) {
83
83
Some ( k) => k,
@@ -92,32 +92,34 @@ where
92
92
93
93
match key {
94
94
k if k. eq_ignore_ascii_case ( b"METADATA_BLOCK_PICTURE" ) => {
95
- let Ok ( picture) = Picture :: from_flac_bytes ( value, true ) else {
96
- if parse_mode == ParsingMode :: Strict {
97
- return Err ( e) ;
98
- }
99
-
100
- log:: warn!( "Failed to decode FLAC picture, discarding field" ) ;
101
- continue ;
102
- } ;
103
-
104
- tag. pictures . push ( picture)
95
+ match Picture :: from_flac_bytes ( value, true ) {
96
+ Ok ( picture) => tag. pictures . push ( picture) ,
97
+ Err ( e) => {
98
+ if parse_mode == ParsingMode :: Strict {
99
+ return Err ( e) ;
100
+ }
101
+
102
+ log:: warn!( "Failed to decode FLAC picture, discarding field" ) ;
103
+ continue ;
104
+ } ,
105
+ }
105
106
} ,
106
107
// The valid range is 0x20..=0x7D not including 0x3D
107
- k if k. iter ( ) . all ( |c| ( b' ' ..=b'}' ) . contains ( c) && c != b'=' ) => {
108
+ k if k. iter ( ) . all ( |c| ( b' ' ..=b'}' ) . contains ( c) && * c != b'=' ) => {
108
109
// SAFETY: We just verified that all of the bytes fall within the subset of ASCII
109
110
let key = unsafe { String :: from_utf8_unchecked ( k. to_vec ( ) ) } ;
110
111
111
- let Ok ( value) = String :: from_utf8 ( value. to_vec ( ) ) else {
112
- if parse_mode == ParsingMode :: Strict {
113
- decode_err ! ( @BAIL "OGG: Vorbis comments contain a non UTF-8 field value" ) ;
114
- }
115
-
116
- log:: warn!( "Non UTF-8 value found, discarding field" ) ;
117
- continue ;
118
- } ;
119
-
120
- tag. items . push ( ( key, value) )
112
+ match String :: from_utf8 ( value. to_vec ( ) ) {
113
+ Ok ( value) => tag. items . push ( ( key, value) ) ,
114
+ Err ( e) => {
115
+ if parse_mode == ParsingMode :: Strict {
116
+ return Err ( LoftyError :: new ( ErrorKind :: StringFromUtf8 ( e) ) ) ;
117
+ }
118
+
119
+ log:: warn!( "Non UTF-8 value found, discarding field" ) ;
120
+ continue ;
121
+ } ,
122
+ }
121
123
} ,
122
124
_ => {
123
125
parse_mode_choice ! (
0 commit comments