From 88343ab24d2b49400cb8b070efc67ee8a77821ba Mon Sep 17 00:00:00 2001 From: Vincent Verschuren Date: Sun, 31 Jul 2022 14:47:10 +0200 Subject: [PATCH] Added workaround for APE v1 tags where binary tags are treated as string tags because v1 doesn't use flags. --- src/TaglibSharp/Ape/Item.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/TaglibSharp/Ape/Item.cs b/src/TaglibSharp/Ape/Item.cs index de65c3d9a..e248e5ecb 100644 --- a/src/TaglibSharp/Ape/Item.cs +++ b/src/TaglibSharp/Ape/Item.cs @@ -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