Skip to content

Commit 7dda538

Browse files
authored
fix: parse correctly the null character (#43)
* fix: parse correctly the null character Some ID3v2 have an \0 null character as a year. `int.parse()`throws an exception if it can't translate the string into an integer. * use tryParse just in case
1 parent 78e8c79 commit 7dda538

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/src/parsers/id3v2.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ class ID3v2Parser extends TagParser {
205205

206206
// 10 -> frame header
207207
offset = offset + 10 + frame.size;
208-
209208
processFrame(frame.id, frame.size);
210209
}
211210

@@ -674,13 +673,13 @@ class ID3v2Parser extends TagParser {
674673
return tagIdentity == "TAG";
675674
}
676675

677-
int _parseYear(String year) {
676+
int? _parseYear(String year) {
678677
if (year.contains("-")) {
679-
return int.parse(year.split("-").first);
678+
return int.tryParse(year.split("-").first);
680679
} else if (year.contains("/")) {
681-
return int.parse(year.split("/").first);
680+
return int.tryParse(year.split("/").first);
682681
} else {
683-
return int.parse(year);
682+
return int.tryParse(year);
684683
}
685684
}
686685

0 commit comments

Comments
 (0)