Skip to content

Commit

Permalink
Added workaround for APE v1 tags where binary tags are treated as str…
Browse files Browse the repository at this point in the history
…ing tags because v1 doesn't use flags.
  • Loading branch information
hopla authored and decriptor committed Aug 31, 2024
1 parent 228d5cb commit 88343ab
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/TaglibSharp/Ape/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,17 @@ protected void Parse (ByteVector data, int offset)

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

if (Type == ItemType.Binary)
this.data = new ReadOnlyByteVector (data.Mid (pos + 1, (int)value_length));
else
text = data.Mid (pos + 1, (int)value_length).ToStrings (StringType.UTF8, 0);
// Store both the binary and string representation, because APE v1. tags don't use the flags.
// Because of this the parser can't differentiate between string and binary.
// In this case sting is assumed (because flags == 0).
//
// If we write both string and binary data, the application can still access the binary data by setting the Type to binary.

// Binary representation
this.data = new ReadOnlyByteVector (data.Mid (pos + 1, (int)value_length));

// String representation
text = data.Mid (pos + 1, (int)value_length).ToStrings (StringType.UTF8, 0);
}

#endregion
Expand Down

0 comments on commit 88343ab

Please sign in to comment.