In Assembly:
authorSebastien Pouliot <sebastien@ximian.com>
Sat, 9 May 2009 15:46:30 +0000 (15:46 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Sat, 9 May 2009 15:46:30 +0000 (15:46 -0000)
2009-05-09  Sebastien Pouliot  <sebastien@ximian.com>

* AssemblyInfo.cs: Open up the internals to System.Windows.Browser
(needed right now), System.Windows and System.Xml (needed for an
upcoming patch).

In System.Net:
2009-05-09  Sebastien Pouliot  <sebastien@ximian.com>

* WebHeaderCollection_2_1.cs: When associated with a WebRequest
the header collection items needs to be validated since not all
headers will be valid. Part of fix for DRT#532

svn path=/trunk/mcs/; revision=133826

mcs/class/System.Net/Assembly/AssemblyInfo.cs
mcs/class/System.Net/Assembly/ChangeLog
mcs/class/System.Net/System.Net/ChangeLog
mcs/class/System.Net/System.Net/WebHeaderCollection_2_1.cs

index 3ad5d56276dfb847466e6b25f9eb306bbfc19ccb..c2f8b15b2e94b61ab242c7a0cf4c40d09ddcf2f2 100644 (file)
@@ -57,6 +57,9 @@ using System.Runtime.InteropServices;
 [assembly: AssemblyDelaySign (true)]
 #if NET_2_1
        [assembly: AssemblyKeyFile ("../silverlight.pub")]
+       [assembly: InternalsVisibleTo ("System.Windows, PublicKey=00240000048000009400000006020000002400005253413100040000010001008D56C76F9E8649383049F383C44BE0EC204181822A6C31CF5EB7EF486944D032188EA1D3920763712CCB12D75FB77E9811149E6148E5D32FBAAB37611C1878DDC19E20EF135D0CB2CFF2BFEC3D115810C3D9069638FE4BE215DBF795861920E5AB6F7DB2E2CEEF136AC23D5DD2BF031700AEC232F6C6B1C785B4305C123B37AB")]
+       [assembly: InternalsVisibleTo ("System.Windows.Browser, PublicKey=00240000048000009400000006020000002400005253413100040000010001008D56C76F9E8649383049F383C44BE0EC204181822A6C31CF5EB7EF486944D032188EA1D3920763712CCB12D75FB77E9811149E6148E5D32FBAAB37611C1878DDC19E20EF135D0CB2CFF2BFEC3D115810C3D9069638FE4BE215DBF795861920E5AB6F7DB2E2CEEF136AC23D5DD2BF031700AEC232F6C6B1C785B4305C123B37AB")]
+       [assembly: InternalsVisibleTo ("System.Xml, PublicKey=00240000048000009400000006020000002400005253413100040000010001008D56C76F9E8649383049F383C44BE0EC204181822A6C31CF5EB7EF486944D032188EA1D3920763712CCB12D75FB77E9811149E6148E5D32FBAAB37611C1878DDC19E20EF135D0CB2CFF2BFEC3D115810C3D9069638FE4BE215DBF795861920E5AB6F7DB2E2CEEF136AC23D5DD2BF031700AEC232F6C6B1C785B4305C123B37AB")]
 #else
        [assembly: AssemblyKeyFile ("../ecma.pub")]
        [assembly: AllowPartiallyTrustedCallers]
index bf699df51200cf62e521ef076f416fd67048b22a..355e895717a93fef71805aed4dcbd4219df2499a 100644 (file)
@@ -1,3 +1,9 @@
+2009-05-09  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * AssemblyInfo.cs: Open up the internals to System.Windows.Browser
+       (needed right now), System.Windows and System.Xml (needed for an
+       upcoming patch).
+
 2009-04-09  Sebastien Pouliot  <sebastien@ximian.com>
 
        * AssemblyInfo.cs: Adjust attributes for 2.1
index 745694f4d130a13e4de8c0b6420a1a4d1abcf8bb..ec79ff1ab2a6bf88fc18638413ac88ebef039007 100644 (file)
@@ -1,3 +1,9 @@
+2009-05-09  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * WebHeaderCollection_2_1.cs: When associated with a WebRequest 
+       the header collection items needs to be validated since not all
+       headers will be valid. Part of fix for DRT#532
+
 2009-04-16  Sebastien Pouliot  <sebastien@ximian.com> 
 
        * HttpWebRequest_2_1.cs: Rework the throwing of NIE so gui-compare
index 9bad231cab4cd808c4beaabed0b75a81cfe49ab9..e6a4dc8cc19d79495a406cf7d406799819e2fc34 100644 (file)
@@ -3,8 +3,9 @@
 //
 // Authors:
 //     Jb Evain  <jbevain@novell.com>
+//     Sebastien Pouliot  <sebastien@ximian.com>
 //
-// (c) 2007 Novell, Inc. (http://www.novell.com)
+// (c) 2007, 2009 Novell, Inc. (http://www.novell.com)
 //
 
 //
@@ -38,12 +39,19 @@ namespace System.Net {
 
        public class WebHeaderCollection : IEnumerable {
 
-               Dictionary<string, string> headers = new Dictionary<string, string> ();
+               internal Dictionary<string, string> headers = new Dictionary<string, string> ();
+               bool validate;
 
                public WebHeaderCollection ()
+                       : this (false)
                {
                }
 
+               internal WebHeaderCollection (bool restrict)
+               {
+                       validate = restrict;
+               }
+
                public int Count {
                        get { return headers.Count; }
                }
@@ -61,11 +69,9 @@ namespace System.Net {
                                if (header == null)
                                        throw new ArgumentNullException ("header");
 
-                               string value;
-                               if (headers.TryGetValue (header, out value))
-                                       return value;
-
-                               return null;
+                               string value = null;
+                               headers.TryGetValue (header.ToLowerInvariant (), out value);
+                               return value;
                        }
                        set {
                                if (header == null)
@@ -73,13 +79,21 @@ namespace System.Net {
                                if (header.Length == 0)
                                        throw new ArgumentException ("header");
 
+                               header = header.ToLowerInvariant ();
+                               if (validate)
+                                       ValidateHeader (header);
                                headers [header] = value;
                        }
                }
 
                public string this [HttpRequestHeader header] {
                        get { return this [HttpRequestHeaderToString (header)]; }
-                       set { this [HttpRequestHeaderToString (header)] = value; }
+                       set {
+                               string h = HttpRequestHeaderToString (header);
+                               if (validate)
+                                       ValidateHeader (h);
+                               headers [h] = value;
+                       }
                }
 
                IEnumerator IEnumerable.GetEnumerator ()
@@ -173,6 +187,72 @@ namespace System.Net {
                                throw new IndexOutOfRangeException ();
                        }
                }
+
+               internal static void ValidateHeader (string header)
+               {
+                       switch (header) {
+                       case "connection":
+                       case "date":
+                       case "keep-alive":
+                       case "trailer":
+                       case "transfer-encoding":
+                       case "upgrade":
+                       case "via":
+                       case "warning":
+                       case "allow":
+                       case "content-length":
+                       case "content-type":
+                       case "content-location":
+                       case "content-range":
+                       case "last-modified":
+                       case "accept":
+                       case "accept-charset":
+                       case "accept-encoding":
+                       case "accept-language":
+                       case "authorization":
+                       case "cookie":
+                       case "expect":
+                       case "host":
+                       case "if-modified-since":
+                       case "max-forwards":
+                       case "proxy-authorization":
+                       case "referer":
+                       case "range":
+                       case "te":
+                       case "user-agent":
+                       // extra (not HttpRequestHeader defined) headers that are not accepted by SL2
+                       // note: the HttpResponseHeader enum is not available in SL2
+                       case "accept-ranges":
+                       case "age":
+                       case "allowed":
+                       case "connect":
+                       case "content-transfer-encoding":
+                       case "delete":
+                       case "etag":
+                       case "get":
+                       case "head":
+                       case "location":
+                       case "options":
+                       case "post":
+                       case "proxy-authenticate":
+                       case "proxy-connection":
+                       case "public":
+                       case "put":
+                       case "request-range":
+                       case "retry-after":
+                       case "server":
+                       case "sec-headertest":
+                       case "sec-":
+                       case "trace":
+                       case "uri":
+                       case "vary":
+                       case "www-authenticate":
+                       case "x-flash-version":
+                               throw new ArgumentException ();
+                       default:
+                               return;
+                       }
+               }
        }
 }