Skip to content

Commit 88343ab

Browse files
hopladecriptor
authored andcommitted
Added workaround for APE v1 tags where binary tags are treated as string tags because v1 doesn't use flags.
1 parent 228d5cb commit 88343ab

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Diff for: src/TaglibSharp/Ape/Item.cs

+11-4
Original file line numberDiff line numberDiff line change
@@ -466,10 +466,17 @@ protected void Parse (ByteVector data, int offset)
466466

467467
Size = pos + 1 + (int)value_length - offset;
468468

469-
if (Type == ItemType.Binary)
470-
this.data = new ReadOnlyByteVector (data.Mid (pos + 1, (int)value_length));
471-
else
472-
text = data.Mid (pos + 1, (int)value_length).ToStrings (StringType.UTF8, 0);
469+
// Store both the binary and string representation, because APE v1. tags don't use the flags.
470+
// Because of this the parser can't differentiate between string and binary.
471+
// In this case sting is assumed (because flags == 0).
472+
//
473+
// If we write both string and binary data, the application can still access the binary data by setting the Type to binary.
474+
475+
// Binary representation
476+
this.data = new ReadOnlyByteVector (data.Mid (pos + 1, (int)value_length));
477+
478+
// String representation
479+
text = data.Mid (pos + 1, (int)value_length).ToStrings (StringType.UTF8, 0);
473480
}
474481

475482
#endregion

0 commit comments

Comments
 (0)