2007-11-05 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Mon, 5 Nov 2007 22:13:41 +0000 (22:13 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Mon, 5 Nov 2007 22:13:41 +0000 (22:13 -0000)
* HttpRequestTest.cs: added a test for case when the query string
is null.
2007-11-05  Marek Habersack  <mhabersack@novell.com>

* HttpRequest.cs: cope with UriBuilder.Query being null.

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

mcs/class/System.Web/System.Web/ChangeLog
mcs/class/System.Web/System.Web/HttpRequest.cs
mcs/class/System.Web/Test/System.Web/ChangeLog
mcs/class/System.Web/Test/System.Web/HttpRequestTest.cs

index a3c30646f767377cb82c05b4a0880d29edd7de97..fcdff7d25627b5ed1d518f56f5aba148047a45ac 100644 (file)
@@ -1,3 +1,7 @@
+2007-11-05  Marek Habersack  <mhabersack@novell.com>
+
+       * HttpRequest.cs: cope with UriBuilder.Query being null.
+
 2007-11-03  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * HttpRuntime.cs: Always return a path with trailing directory
index 6f5c37de940db0b9fedd14625d223b4e3fe22da6..16e12ff59b22d88a18c10e6de2d172583c427813 100644 (file)
@@ -112,8 +112,9 @@ namespace System.Web {
                        url_components = new UriBuilder (url);
                        url_components.Query = queryString;
                        
-                       query_string_nvc = new WebROCollection ();                                      
-                       HttpUtility.ParseQueryString (queryString, Encoding.Default, query_string_nvc);
+                       query_string_nvc = new WebROCollection ();
+                       if (queryString != null)
+                               HttpUtility.ParseQueryString (queryString, Encoding.Default, query_string_nvc);
                        query_string_nvc.Protect ();
                }
 
@@ -973,13 +974,16 @@ namespace System.Web {
 
                public NameValueCollection QueryString {
                        get {
-                               if (query_string_nvc == null){
+                               if (query_string_nvc == null) {
+                                       query_string_nvc = new WebROCollection ();
                                        string q = UrlComponents.Query;
-                                       if (q.Length != 0)
-                                               q = q.Remove(0, 1);
-
-                                       query_string_nvc = new WebROCollection ();                                      
-                                       HttpUtility.ParseQueryString (q, ContentEncoding, query_string_nvc);
+                                       if (q != null) {
+                                               if (q.Length != 0)
+                                                       q = q.Remove(0, 1);
+                                       
+                                               HttpUtility.ParseQueryString (q, ContentEncoding, query_string_nvc);
+                                       }
+                                       
                                        query_string_nvc.Protect();
                                }
                                
index 78f47af9c314eb4f3297467f2b7d1c5627058d43..6aea478eb4b869817face206fac65452f044f575 100644 (file)
@@ -1,3 +1,8 @@
+2007-11-05  Marek Habersack  <mhabersack@novell.com>
+
+       * HttpRequestTest.cs: added a test for case when the query string
+       is null.
+
 2007-10-30 Igor Zelmanovich <igorz@mainsoft.com>
 
        * HttpUtilityTest.cs: added new test.
index e2e53716692ae38dfa922aeacd649f6c096f4598..14992663c3b9f835e5ab3e353187bcbe47522f4b 100644 (file)
@@ -662,6 +662,16 @@ namespace MonoTests.System.Web {
                        c = Cook (51);
                        Assert.AreEqual (c.Request.QueryString.ToString (), "Plain&Arg=1", "QTS#2");
                }
+
+#if NET_2_0
+               [Test]
+               public void QueryString_NullTest ()
+               {
+                       HttpRequest req = new HttpRequest ("file.aspx", "http://localhost/file.aspx", null);
+                       
+                       Assert.AreEqual (req.QueryString.ToString (), "", "QSNT#1");
+               }
+#endif
                
                [Test]
                public void Leading_qm_in_QueryString ()