2008-08-19 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Tue, 19 Aug 2008 10:34:46 +0000 (10:34 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Tue, 19 Aug 2008 10:34:46 +0000 (10:34 -0000)
* UrlUtils.cs: fail gracefully if the path passed to GetSessionId
is null.

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

mcs/class/System.Web/System.Web.Util/ChangeLog
mcs/class/System.Web/System.Web.Util/UrlUtils.cs

index 3f1c50d0bc09323ecb8a142aa04dd327a3558686..8a76b00ddd54f2faf2f5fc2263deb0a5e963f992 100644 (file)
@@ -1,3 +1,8 @@
+2008-08-19  Marek Habersack  <mhabersack@novell.com>
+
+       * UrlUtils.cs: fail gracefully if the path passed to GetSessionId
+       is null.
+
 2008-07-29  Marek Habersack  <mhabersack@novell.com>
 
        * UrlUtils.cs: fixed a typo in HasSessionId which made it always
index 3cfdb244b1cc5971ba34a615857ae2f912ac7558..b55e245c7c5c9c1479ab933f532e763dcd8b9e9f 100644 (file)
@@ -57,15 +57,23 @@ namespace System.Web.Util {
 
                internal static string GetSessionId (string path)
                {
+                       if (path == null)
+                               return null;
+
                        string appvpath = HttpRuntime.AppDomainAppVirtualPath;
-                       if (path.Length <= appvpath.Length)
+                       int appvpathlen = appvpath.Length;
+
+                       if (path.Length <= appvpathlen)
                                return null;
 
-                       path = path.Substring (appvpath.Length);
-                       if (path.Length == 0 || path [0] != '/')
+                       path = path.Substring (appvpathlen);
+                       
+                       int len = path.Length;
+                       if (len == 0 || path [0] != '/') {
                                path = '/' + path;
+                               len++;
+                       }                       
 
-                       int len = path.Length;
                        if ((len < SessionId.IdLength + 3) || (path [1] != '(') ||
                            (path [SessionId.IdLength + 2] != ')'))
                                return null;