Author: atsushi
Date: 2008-02-16 02:58:49 -0500 (Sat, 16 Feb 2008)
New Revision: 95854

Added:
   trunk/mcs/class/System/Test/System.Net.Mime/ChangeLog
Modified:
   trunk/mcs/class/System/System.Net.Mime/ChangeLog
   trunk/mcs/class/System/System.Net.Mime/ContentType.cs
   trunk/mcs/class/System/Test/System.Net.Mime/ContentTypeTest.cs
Log:
2008-02-16  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * ContentType.cs : Reject such MediaType that lacks '/'.
          Do not reject such parameters that are not standard ones.

        * ContentTypeTest.cs : (oops we didn't have ChangeLog here) added
          another .ctor() test.



Modified: trunk/mcs/class/System/System.Net.Mime/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net.Mime/ChangeLog    2008-02-16 07:57:41 UTC 
(rev 95853)
+++ trunk/mcs/class/System/System.Net.Mime/ChangeLog    2008-02-16 07:58:49 UTC 
(rev 95854)
@@ -1,3 +1,8 @@
+2008-02-16  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * ContentType.cs : Reject such MediaType that lacks '/'.
+         Do not reject such parameters that are not standard ones.
+
 2007-12-05  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * ContentType.cs : for SubjectEncoding, null is returned instead of 

Modified: trunk/mcs/class/System/System.Net.Mime/ContentType.cs
===================================================================
--- trunk/mcs/class/System/System.Net.Mime/ContentType.cs       2008-02-16 
07:57:41 UTC (rev 95853)
+++ trunk/mcs/class/System/System.Net.Mime/ContentType.cs       2008-02-16 
07:58:49 UTC (rev 95854)
@@ -61,22 +61,16 @@
                        if (contentType.Length < 1)
                                throw new ArgumentException ("contentType");
 
-                       try {
-                               int index = contentType.IndexOf (";");
-                               if (index > 0) {
-                                       string[] split = contentType.Split 
(';');
-                                       this.mediaType = split[0].Trim ();
-                                       for (int i = 1; i < split.Length; i++)
-                                       {
-                                               Parse (split[i]);
-                                       }
-                               }
-                               else {
-                                       this.mediaType = contentType.Trim ();
-                               }
-                       } catch {
-                               throw new FormatException ();
+                       int index = contentType.IndexOf (';');
+                       if (index > 0) {
+                               string[] split = contentType.Split (';');
+                               this.MediaType = split[0].Trim ();
+                               for (int i = 1; i < split.Length; i++)
+                                       Parse (split[i]);
                        }
+                       else {
+                               this.MediaType = contentType.Trim ();
+                       }
                }
 
                // parse key=value pairs like:
@@ -87,18 +81,8 @@
                                return;
 
                        string[] split = pair.Split ('=');
-                       if (split.Length == 2) {
-                               switch (split[0].Trim ()) {
-                                       case "boundary":
-                                       case "charset":
-                                       case "name":
-                                               parameters.Add (split[0].Trim 
(), split[1].Trim ());
-                                               break;
-                                       default:
-                                               // apparently parameters must 
go through Parameters.Add
-                                               throw new FormatException 
("invalid content-type format");
-                               }
-                       }
+                       if (split.Length == 2)
+                               parameters.Add (split[0].Trim (), split[1].Trim 
());
                }
 
                #endregion // Constructors
@@ -130,6 +114,8 @@
                                        throw new ArgumentNullException ();
                                if (value.Length < 1)
                                        throw new ArgumentException ();
+                               if (value.IndexOf ('/') < 1)
+                                       throw new FormatException ();
                                if (value.IndexOf (';') != -1)
                                        throw new FormatException ();
                                mediaType = value;

Added: trunk/mcs/class/System/Test/System.Net.Mime/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/System.Net.Mime/ChangeLog       2008-02-16 
07:57:41 UTC (rev 95853)
+++ trunk/mcs/class/System/Test/System.Net.Mime/ChangeLog       2008-02-16 
07:58:49 UTC (rev 95854)
@@ -0,0 +1,4 @@
+2008-02-16  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * ContentTypeTest.cs : (oops we didn't have ChangeLog here) added
+         another .ctor() test.

Modified: trunk/mcs/class/System/Test/System.Net.Mime/ContentTypeTest.cs
===================================================================
--- trunk/mcs/class/System/Test/System.Net.Mime/ContentTypeTest.cs      
2008-02-16 07:57:41 UTC (rev 95853)
+++ trunk/mcs/class/System/Test/System.Net.Mime/ContentTypeTest.cs      
2008-02-16 07:58:49 UTC (rev 95854)
@@ -42,10 +42,16 @@
                [ExpectedException (typeof (FormatException))]
                public void FormatException ()
                {
-                       new ContentType ("attachment; foo=bar");
+                       new ContentType ("attachment; foo=bar"); // missing '/'
                }
 
                [Test]
+               public void ArbitraryParameter ()
+               {
+                       new ContentType ("application/xml; foo=bar");
+               }
+
+               [Test]
                public void Boundary ()
                {
                        Assert.IsNull (ct.Boundary);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to