فهرست منبع

2009-06-08 Gonzalo Paniagua Javier <[email protected]>

	* HttpHandlerAction.cs: fix path matching when the pattern has more
	than one slash.


svn path=/trunk/mcs/; revision=135685
Gonzalo Paniagua Javier 16 سال پیش
والد
کامیت
aa9460908c

+ 5 - 0
mcs/class/System.Web/System.Web.Configuration_2.0/ChangeLog

@@ -1,3 +1,8 @@
+2009-06-08 Gonzalo Paniagua Javier <[email protected]>
+
+	* HttpHandlerAction.cs: fix path matching when the pattern has more
+	than one slash.
+
 2009-06-05  Marek Habersack  <[email protected]>
 
 	* WebConfigurationManager.cs: OpenWebConfiguration caches

+ 27 - 2
mcs/class/System.Web/System.Web.Configuration_2.0/HttpHandlerAction.cs

@@ -174,7 +174,7 @@ namespace System.Web.Configuration
 		{
 			if (String.IsNullOrEmpty (pathToMatch))
 				return false;
-			
+
 			bool result = false;
 			string[] handlerPaths = Path.Split (',');
 			int slash = pathToMatch.LastIndexOf ('/');
@@ -251,7 +251,10 @@ namespace System.Web.Configuration
 					else
 						noLeadingSlashPathToMatch = origPathToMatch;
 				}
-					
+
+				if (pattern.IndexOf ('/') >= 0)
+					noLeadingSlashPathToMatch = AdjustPath (pattern, noLeadingSlashPathToMatch);
+
 				if (sp.IsMatch (noLeadingSlashPathToMatch)) {
 					result = true;
 					break;
@@ -261,6 +264,28 @@ namespace System.Web.Configuration
 			return result;
 		}
 
+		static string AdjustPath (string pattern, string path)
+		{
+			int nslashes = 0;
+			foreach (char c in pattern)
+				if (c == '/')
+					nslashes++;
+
+			int i;
+			for (i = path.Length - 1; i >= 0; i--) {
+				if (path [i] == '/') {
+					nslashes--;
+					if (nslashes == -1)
+						break;
+				}
+			}
+
+			if (nslashes >= 0 || i == 0)
+				return path;
+
+			return path.Substring (i + 1);
+		}
+
 		// Loads the handler, possibly delay-loaded.
 		internal object GetHandlerInstance ()
 		{