Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added workaround for APE v1 where binary tags are treated as string #303

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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