Skip to content
Open
Show file tree
Hide file tree
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/Id3.Net/Id3/v2/Id3v23Handler.Frames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,17 @@ private static Id3Frame DecodePrivate(byte[] data)
var frame = new PrivateFrame();
byte[] splitterSequence = TextEncodingHelper.GetSplitterBytes(Id3TextEncoding.Iso8859_1);
byte[] ownerIdBytes = ByteArrayHelper.GetBytesUptoSequence(data, 0, splitterSequence);
frame.OwnerId =
TextEncodingHelper.GetString(ownerIdBytes, 0, ownerIdBytes.Length, Id3TextEncoding.Iso8859_1);
frame.Data = new byte[data.Length - ownerIdBytes.Length - splitterSequence.Length];
Array.Copy(data, ownerIdBytes.Length + splitterSequence.Length, frame.Data, 0, frame.Data.Length);
if(ownerIdBytes != null)
{
frame.OwnerId =
TextEncodingHelper.GetString(ownerIdBytes, 0, ownerIdBytes.Length, Id3TextEncoding.Iso8859_1);
frame.Data = new byte[data.Length - ownerIdBytes.Length - splitterSequence.Length];
Array.Copy(data, ownerIdBytes.Length + splitterSequence.Length, frame.Data, 0, frame.Data.Length);
}
else
{
frame.Data = new byte[0];
}
return frame;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Id3.Net/Utils/TextEncodingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal static string GetString(byte[] bytes, int start, int count, Id3TextEnco
Encoding encoding = GetEncoding(encodingType);
string str = encoding.GetString(bytes, start, count);

if (encodingType == Id3TextEncoding.Unicode)
if (str.Length > 0 && encodingType == Id3TextEncoding.Unicode)
{
if (str[0] == '\xFFFE' || str[0] == '\xFEFF')
str = str.Remove(0, 1);
Expand Down