Author: gonzalo
Date: 2006-01-31 17:00:13 -0500 (Tue, 31 Jan 2006)
New Revision: 56368
Modified:
trunk/mcs/class/System.Web/System.Web.Util/ChangeLog
trunk/mcs/class/System.Web/System.Web.Util/UrlUtils.cs
Log:
2006-01-31 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* UrlUtils.cs: more than one consecutive slash are turned into one.
Modified: trunk/mcs/class/System.Web/System.Web.Util/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Util/ChangeLog 2006-01-31
21:41:32 UTC (rev 56367)
+++ trunk/mcs/class/System.Web/System.Web.Util/ChangeLog 2006-01-31
22:00:13 UTC (rev 56368)
@@ -1,3 +1,7 @@
+2006-01-31 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+ * UrlUtils.cs: more than one consecutive slash are turned into one.
+
2006-01-26 Chris Toshok <[EMAIL PROTECTED]>
* WebEncoding.cs: rework this so we cache the section, and so we
Modified: trunk/mcs/class/System.Web/System.Web.Util/UrlUtils.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Util/UrlUtils.cs 2006-01-31
21:41:32 UTC (rev 56367)
+++ trunk/mcs/class/System.Web/System.Web.Util/UrlUtils.cs 2006-01-31
22:00:13 UTC (rev 56368)
@@ -177,17 +177,41 @@
{
url = url.Replace('\\','/');
int last = url.LastIndexOf ('/');
- if (last > 0)
+
+ if (last > 0) {
+#if NET_2_0
+ return RemoveDoubleSlashes (url.Substring (0,
last));
+#else
return url.Substring (0, last);
+#endif
+ }
+
return "/";
}
+#if NET_2_0
+ internal static string RemoveDoubleSlashes (string input)
+ {
+ // MS VirtualPathUtility removes duplicate '/'
+ string str = input;
+ string x;
+ while ((x = str.Replace ("//", "/")) != str) {
+ str = x;
+ }
+
+ return str;
+ }
+#endif
+
internal static string GetFile (string url)
{
url = url.Replace('\\','/');
int last = url.LastIndexOf ('/');
- if (last >= 0)
+ if (last >= 0) {
+ if (url.Length == 1) // Empty file name instead
of ArgumentOutOfRange
+ return "";
return url.Substring (last+1);
+ }
throw new Exception (String.Format ("GetFile: `{0}'
does not contain a /", url));
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches