Skip to content

Commit 78e8c79

Browse files
authored
fix: ID3v2 wasn't parsing description as UTF-16 (#42)
* fix(id3v2): image's description can be UTF-16 * fix: decription must increase offset
1 parent 97c84cb commit 78e8c79

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/src/parsers/id3v2.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,10 @@ class ID3v2Parser extends TagParser {
556556
}
557557

558558
Picture getPicture(Uint8List content) {
559-
var offset = 1;
559+
int offset = 0;
560560

561561
final reader = ByteData.sublistView(content);
562+
final encoding = reader.getUint8(offset++);
562563

563564
final mimetype = [reader.getUint8(offset++)];
564565

@@ -572,13 +573,16 @@ class ID3v2Parser extends TagParser {
572573

573574
offset++;
574575

575-
final description = [reader.getUint8(offset)];
576-
offset += 1;
576+
final description = [reader.getInt8(offset++)];
577577

578578
while (description.last != 0) {
579-
final a = reader.getUint8(offset);
580-
description.add(a);
581-
offset++;
579+
description.add(reader.getInt8(offset++));
580+
}
581+
582+
if (encoding == 1 || encoding == 2) {
583+
while (reader.getInt8(offset) == 0) {
584+
offset++;
585+
}
582586
}
583587

584588
return Picture(

0 commit comments

Comments
 (0)