Author: bnickel
Date: 2007-06-20 16:49:35 -0400 (Wed, 20 Jun 2007)
New Revision: 80364
Modified:
trunk/taglib-sharp/ChangeLog
trunk/taglib-sharp/src/TagLib/Asf/Tag.cs
trunk/taglib-sharp/src/TagLib/ByteVector.cs
trunk/taglib-sharp/src/TagLib/Id3v2/Frame.cs
trunk/taglib-sharp/src/TagLib/Id3v2/Frames/AttachedPictureFrame.cs
trunk/taglib-sharp/src/TagLib/Id3v2/Frames/CommentsFrame.cs
trunk/taglib-sharp/src/TagLib/Id3v2/Frames/GeneralEncapsulatedObjectFrame.cs
trunk/taglib-sharp/src/TagLib/Id3v2/Frames/PrivateFrame.cs
trunk/taglib-sharp/src/TagLib/Id3v2/Frames/RelativeVolumeFrame.cs
trunk/taglib-sharp/src/TagLib/Id3v2/Frames/SynchronizedLyricsFrame.cs
trunk/taglib-sharp/src/TagLib/Id3v2/Frames/TextIdentificationFrame.cs
trunk/taglib-sharp/src/TagLib/Id3v2/Frames/UniqueFileIdentifierFrame.cs
trunk/taglib-sharp/src/TagLib/Id3v2/Frames/UnsynchronisedLyricsFrame.cs
Log:
2007-06-20 Brian Nickel <[EMAIL PROTECTED]>
* src/TagLib/Id3v2/Frames/UnsynchronisedLyricsFrame.cs:
* src/TagLib/Id3v2/Frames/RelativeVolumeFrame.cs:
* src/TagLib/Id3v2/Frames/CommentsFrame.cs:
* src/TagLib/Id3v2/Frames/SynchronizedLyricsFrame.cs:
* src/TagLib/Id3v2/Frames/AttachedPictureFrame.cs:
* src/TagLib/Id3v2/Frames/UniqueFileIdentifierFrame.cs:
* src/TagLib/Id3v2/Frames/PrivateFrame.cs:
* src/TagLib/Id3v2/Frames/GeneralEncapsulatedObjectFrame.cs:
* src/TagLib/Id3v2/Frames/TextIdentificationFrame.cs: Use
ByteVector.TextDelimiter instead of Frame.TextDelimiter.
* src/TagLib/Id3v2/Frame.cs: Mark TextDelimiter as obsolete.
* src/TagLib/ByteVector.cs: Add TextDelimiter method.
* src/TagLib/Asf/Tag.cs: Discard new pictures if their rendered size is
greater than 64KB to avoid corrupting files. (Thanks to renzska for the
bug report.)
Modified: trunk/taglib-sharp/ChangeLog
===================================================================
--- trunk/taglib-sharp/ChangeLog 2007-06-20 20:34:41 UTC (rev 80363)
+++ trunk/taglib-sharp/ChangeLog 2007-06-20 20:49:35 UTC (rev 80364)
@@ -1,5 +1,25 @@
2007-06-20 Brian Nickel <[EMAIL PROTECTED]>
+ * src/TagLib/Id3v2/Frames/UnsynchronisedLyricsFrame.cs:
+ * src/TagLib/Id3v2/Frames/RelativeVolumeFrame.cs:
+ * src/TagLib/Id3v2/Frames/CommentsFrame.cs:
+ * src/TagLib/Id3v2/Frames/SynchronizedLyricsFrame.cs:
+ * src/TagLib/Id3v2/Frames/AttachedPictureFrame.cs:
+ * src/TagLib/Id3v2/Frames/UniqueFileIdentifierFrame.cs:
+ * src/TagLib/Id3v2/Frames/PrivateFrame.cs:
+ * src/TagLib/Id3v2/Frames/GeneralEncapsulatedObjectFrame.cs:
+ * src/TagLib/Id3v2/Frames/TextIdentificationFrame.cs: Use
+ ByteVector.TextDelimiter instead of Frame.TextDelimiter.
+
+ * src/TagLib/Id3v2/Frame.cs: Mark TextDelimiter as obsolete.
+ * src/TagLib/ByteVector.cs: Add TextDelimiter method.
+
+ * src/TagLib/Asf/Tag.cs: Discard new pictures if their rendered size is
+ greater than 64KB to avoid corrupting files. (Thanks to renzska for the
+ bug report.)
+
+2007-06-20 Brian Nickel <[EMAIL PROTECTED]>
+
* src/TagLib/Id3v1/Tag.cs: Rework to match Picard specs.
* src/TagLib/Riff/DivXTag.cs: Rework to match Picard specs.
Modified: trunk/taglib-sharp/src/TagLib/Asf/Tag.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Asf/Tag.cs 2007-06-20 20:34:41 UTC (rev
80363)
+++ trunk/taglib-sharp/src/TagLib/Asf/Tag.cs 2007-06-20 20:49:35 UTC (rev
80364)
@@ -328,13 +328,13 @@
int size = (int) data.Mid (offset, 4).ToUInt (false);
offset += 4;
- int found = data.Find ("\0\0", offset, 2);
+ int found = data.Find (ByteVector.TextDelimiter
(StringType.UTF16LE), offset, 2);
if (found == -1)
continue;
p.MimeType = data.Mid (offset, found - offset).ToString
(StringType.UTF16LE);
offset = found + 2;
- found = data.Find ("\0\0", offset, 2);
+ found = data.Find (ByteVector.TextDelimiter
(StringType.UTF16LE), offset, 2);
if (found == -1)
continue;
p.Description = data.Mid (offset, found -
offset).ToString (StringType.UTF16LE);
@@ -356,19 +356,23 @@
return;
}
- ContentDescriptor [] descriptors = new ContentDescriptor
[value.Length];
+ List<ContentDescriptor> descriptors = new
List<ContentDescriptor> ();
for (int i = 0; i < value.Length; i ++)
{
ByteVector v = new ByteVector ((byte) value [i].Type);
v.Add (Object.RenderDWord ((uint) value
[i].Data.Count));
v.Add (Object.RenderUnicode (value [i].MimeType));
v.Add (Object.RenderUnicode (value [i].Description));
+
+ /// If its too big, ignore it.
+ if (v.Count > 0xFFFF - value [i].Data.Count)
+ continue;
+
v.Add (value [i].Data);
-
- descriptors [i] = new ContentDescriptor ("WM/Picture", v);
+ descriptors [i] = new ContentDescriptor ("WM/Picture",
v);
}
- SetDescriptors ("WM/Picture", descriptors);
+ SetDescriptors ("WM/Picture", descriptors.ToArray ());
}
}
Modified: trunk/taglib-sharp/src/TagLib/ByteVector.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/ByteVector.cs 2007-06-20 20:34:41 UTC (rev
80363)
+++ trunk/taglib-sharp/src/TagLib/ByteVector.cs 2007-06-20 20:49:35 UTC (rev
80364)
@@ -504,7 +504,7 @@
int pos = offset;
StringCollection l = new StringCollection ();
- ByteVector separator = TagLib.Id3v2.Frame.TextDelimiter (type);
+ ByteVector separator = TextDelimiter (type);
int align = separator.Count;
while (chunk < count && pos < Count)
{
@@ -781,6 +781,13 @@
#region Utilities
+ private static readonly ReadOnlyByteVector td1 = new ReadOnlyByteVector
((int)1);
+ private static readonly ReadOnlyByteVector td2 = new ReadOnlyByteVector
((int)2);
+ public static ByteVector TextDelimiter (StringType type)
+ {
+ return (type == StringType.UTF16 || type == StringType.UTF16BE ||
type == StringType.UTF16LE) ? td2 : td1;
+ }
+
private static System.Text.Encoding last_utf16_encoding =
System.Text.Encoding.Unicode;
private static System.Text.Encoding StringTypeToEncoding(StringType
type, ByteVector bom)
{
Modified: trunk/taglib-sharp/src/TagLib/Id3v2/Frame.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Id3v2/Frame.cs 2007-06-20 20:34:41 UTC
(rev 80363)
+++ trunk/taglib-sharp/src/TagLib/Id3v2/Frame.cs 2007-06-20 20:49:35 UTC
(rev 80364)
@@ -148,10 +148,13 @@
#region Public Static Methods
+
+ [Obsolete("Use ByteVector.TextDelimiter.")]
public static ByteVector TextDelimiter (StringType type)
{
- return new ByteVector ((type == StringType.UTF16 || type ==
StringType.UTF16BE) ? 2 : 1, (byte) 0);
+ return ByteVector.TextDelimiter (type);
}
+
#endregion
Modified: trunk/taglib-sharp/src/TagLib/Id3v2/Frames/AttachedPictureFrame.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Id3v2/Frames/AttachedPictureFrame.cs
2007-06-20 20:34:41 UTC (rev 80363)
+++ trunk/taglib-sharp/src/TagLib/Id3v2/Frames/AttachedPictureFrame.cs
2007-06-20 20:49:35 UTC (rev 80364)
@@ -187,7 +187,7 @@
if (raw_version > 2)
{
- offset = raw_data.Find (TextDelimiter (StringType.Latin1), pos);
+ offset = raw_data.Find (ByteVector.TextDelimiter
(StringType.Latin1), pos);
if(offset < pos)
return;
@@ -210,7 +210,7 @@
type = (PictureType) raw_data [pos++];
- offset = raw_data.Find (TextDelimiter (text_encoding), pos,
byte_align);
+ offset = raw_data.Find (ByteVector.TextDelimiter (text_encoding),
pos, byte_align);
if(offset < pos)
return;
@@ -251,12 +251,12 @@
else
{
data.Add (ByteVector.FromString (MimeType, StringType.Latin1));
- data.Add (TextDelimiter (StringType.Latin1));
+ data.Add (ByteVector.TextDelimiter (StringType.Latin1));
}
data.Add ((byte) type);
data.Add (ByteVector.FromString (Description, encoding));
- data.Add (TextDelimiter (encoding));
+ data.Add (ByteVector.TextDelimiter (encoding));
data.Add (this.data);
return data;
Modified: trunk/taglib-sharp/src/TagLib/Id3v2/Frames/CommentsFrame.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Id3v2/Frames/CommentsFrame.cs 2007-06-20
20:34:41 UTC (rev 80363)
+++ trunk/taglib-sharp/src/TagLib/Id3v2/Frames/CommentsFrame.cs 2007-06-20
20:49:35 UTC (rev 80364)
@@ -189,7 +189,7 @@
v.Add ((byte) encoding);
v.Add (ByteVector.FromString (Language, StringType.Latin1));
v.Add (ByteVector.FromString (description, encoding));
- v.Add (TextDelimiter (encoding));
+ v.Add (ByteVector.TextDelimiter (encoding));
v.Add (ByteVector.FromString (text, encoding));
return v;
Modified:
trunk/taglib-sharp/src/TagLib/Id3v2/Frames/GeneralEncapsulatedObjectFrame.cs
===================================================================
---
trunk/taglib-sharp/src/TagLib/Id3v2/Frames/GeneralEncapsulatedObjectFrame.cs
2007-06-20 20:34:41 UTC (rev 80363)
+++
trunk/taglib-sharp/src/TagLib/Id3v2/Frames/GeneralEncapsulatedObjectFrame.cs
2007-06-20 20:49:35 UTC (rev 80364)
@@ -134,21 +134,21 @@
text_encoding = (StringType) data [field_start++];
int byte_align = text_encoding == StringType.Latin1 || text_encoding
== StringType.UTF8 ? 1 : 2;
- int field_end = data.Find (TextDelimiter (StringType.Latin1),
field_start);
+ int field_end = data.Find (ByteVector.TextDelimiter
(StringType.Latin1), field_start);
if (field_end < field_start)
return;
mime_type = data.Mid (field_start, field_end - field_start).ToString
(StringType.Latin1);
field_start = field_end + 1;
- field_end = data.Find (TextDelimiter (text_encoding), field_start,
byte_align);
+ field_end = data.Find (ByteVector.TextDelimiter (text_encoding),
field_start, byte_align);
if (field_end < field_start)
return;
file_name = data.Mid (field_start, field_end - field_start).ToString
(text_encoding);
field_start = field_end + 1;
- field_end = data.Find (TextDelimiter (text_encoding), field_start,
byte_align);
+ field_end = data.Find (ByteVector.TextDelimiter (text_encoding),
field_start, byte_align);
if (field_end < field_start)
return;
@@ -168,15 +168,15 @@
if (MimeType != null)
v.Add (ByteVector.FromString (MimeType, StringType.Latin1));
- v.Add (TextDelimiter (StringType.Latin1));
+ v.Add (ByteVector.TextDelimiter (StringType.Latin1));
if (FileName != null)
v.Add (ByteVector.FromString (FileName, encoding));
- v.Add (TextDelimiter (encoding));
+ v.Add (ByteVector.TextDelimiter (encoding));
if (Description != null)
v.Add (ByteVector.FromString (Description, encoding));
- v.Add (TextDelimiter (encoding));
+ v.Add (ByteVector.TextDelimiter (encoding));
v.Add (data);
Modified: trunk/taglib-sharp/src/TagLib/Id3v2/Frames/PrivateFrame.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Id3v2/Frames/PrivateFrame.cs 2007-06-20
20:34:41 UTC (rev 80363)
+++ trunk/taglib-sharp/src/TagLib/Id3v2/Frames/PrivateFrame.cs 2007-06-20
20:49:35 UTC (rev 80364)
@@ -105,7 +105,7 @@
if (data.Count < 1)
throw new CorruptFileException ("A private frame must contain at
least 1 byte.");
- ByteVectorCollection l = ByteVectorCollection.Split (data,
TextDelimiter (StringType.Latin1), 1, 2);
+ ByteVectorCollection l = ByteVectorCollection.Split (data,
ByteVector.TextDelimiter (StringType.Latin1), 1, 2);
if (l.Count == 2)
{
@@ -121,7 +121,7 @@
if (version > 2)
{
v.Add (ByteVector.FromString (owner, StringType.Latin1));
- v.Add (TextDelimiter (StringType.Latin1));
+ v.Add (ByteVector.TextDelimiter (StringType.Latin1));
v.Add (data);
}
Modified: trunk/taglib-sharp/src/TagLib/Id3v2/Frames/RelativeVolumeFrame.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Id3v2/Frames/RelativeVolumeFrame.cs
2007-06-20 20:34:41 UTC (rev 80363)
+++ trunk/taglib-sharp/src/TagLib/Id3v2/Frames/RelativeVolumeFrame.cs
2007-06-20 20:49:35 UTC (rev 80364)
@@ -161,7 +161,7 @@
#region Protected Properties
protected override void ParseFields (ByteVector data, byte version)
{
- int pos = data.Find (TextDelimiter (StringType.Latin1));
+ int pos = data.Find (ByteVector.TextDelimiter (StringType.Latin1));
if (pos < 0)
return;
@@ -195,7 +195,7 @@
ByteVector data = new ByteVector ();
data.Add (ByteVector.FromString (identification, StringType.Latin1));
- data.Add (TextDelimiter(StringType.Latin1));
+ data.Add (ByteVector.TextDelimiter(StringType.Latin1));
foreach (ChannelData channel in channels.Values)
{
Modified: trunk/taglib-sharp/src/TagLib/Id3v2/Frames/SynchronizedLyricsFrame.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Id3v2/Frames/SynchronizedLyricsFrame.cs
2007-06-20 20:34:41 UTC (rev 80363)
+++ trunk/taglib-sharp/src/TagLib/Id3v2/Frames/SynchronizedLyricsFrame.cs
2007-06-20 20:49:35 UTC (rev 80364)
@@ -177,7 +177,7 @@
timestamp_format = (TimestampFormat) data [4];
lyrics_type = (SynchedTextType) data [5];
- ByteVector delim = TextDelimiter (text_encoding);
+ ByteVector delim = ByteVector.TextDelimiter (text_encoding);
int delim_index = data.Find (delim, 6);
if (delim_index < 0)
@@ -210,7 +210,7 @@
protected override ByteVector RenderFields (byte version)
{
StringType encoding = CorrectEncoding(TextEncoding, version);
- ByteVector delim = TextDelimiter (encoding);
+ ByteVector delim = ByteVector.TextDelimiter (encoding);
ByteVector v = new ByteVector ();
v.Add ((byte)encoding);
Modified: trunk/taglib-sharp/src/TagLib/Id3v2/Frames/TextIdentificationFrame.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Id3v2/Frames/TextIdentificationFrame.cs
2007-06-20 20:34:41 UTC (rev 80363)
+++ trunk/taglib-sharp/src/TagLib/Id3v2/Frames/TextIdentificationFrame.cs
2007-06-20 20:49:35 UTC (rev 80364)
@@ -188,13 +188,13 @@
{
string value = data.ToString (encoding, 1);
- if (value.Length == 0 || value [0] == '\0')
+ if (value.Length == 0 || value [0] == 0)
goto done;
// Do a fast removal of end bytes.
- if (value.Length > 1 && value [value.Length - 1] == '\0')
+ if (value.Length > 1 && value [value.Length - 1] == 0)
for (int i = value.Length - 1; i >= 0; i --)
- if (value [i] != '\0')
+ if (value [i] != 0)
{
value = value.Substring (0, i + 1);
break;
@@ -253,7 +253,7 @@
// first element in the list, append the appropriate delimiter
// for this encoding.
if (i !=0)
- v.Add (TextDelimiter (encoding));
+ v.Add (ByteVector.TextDelimiter (encoding));
v.Add (ByteVector.FromString (field_list [i], encoding));
}
Modified:
trunk/taglib-sharp/src/TagLib/Id3v2/Frames/UniqueFileIdentifierFrame.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Id3v2/Frames/UniqueFileIdentifierFrame.cs
2007-06-20 20:34:41 UTC (rev 80363)
+++ trunk/taglib-sharp/src/TagLib/Id3v2/Frames/UniqueFileIdentifierFrame.cs
2007-06-20 20:49:35 UTC (rev 80364)
@@ -103,7 +103,7 @@
ByteVector data = new ByteVector ();
data.Add (ByteVector.FromString (owner, StringType.Latin1));
- data.Add (TextDelimiter (StringType.Latin1));
+ data.Add (ByteVector.TextDelimiter (StringType.Latin1));
data.Add (identifier);
return data;
Modified:
trunk/taglib-sharp/src/TagLib/Id3v2/Frames/UnsynchronisedLyricsFrame.cs
===================================================================
--- trunk/taglib-sharp/src/TagLib/Id3v2/Frames/UnsynchronisedLyricsFrame.cs
2007-06-20 20:34:41 UTC (rev 80363)
+++ trunk/taglib-sharp/src/TagLib/Id3v2/Frames/UnsynchronisedLyricsFrame.cs
2007-06-20 20:49:35 UTC (rev 80364)
@@ -171,7 +171,7 @@
v.Add((byte)encoding);
v.Add(ByteVector.FromString (Language, StringType.Latin1));
v.Add(ByteVector.FromString (description, encoding));
- v.Add(TextDelimiter(encoding));
+ v.Add(ByteVector.TextDelimiter(encoding));
v.Add(ByteVector.FromString (text, encoding));
return v;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches