Quellcode durchsuchen

2007-10-24 Marek Habersack <[email protected]>

	* HttpHandlerAction.cs: exact path matching must be done on the
	original string in PathMatches, not on the sliced one. Fixes bug
	#335669.
2007-10-24  Marek Habersack  <[email protected]>

	* HandlerFactoryConfiguration.cs: exact path matching must be done
	on the original string in PathMatches, not on the sliced one.

	* FileMatchingInfo.cs: refactoring - this code used to live in
	both 1.1 and 2.0 profiles. At the same time, fixe the way
	MatchExact is created - the slash is prepended only if the path
	doesn't begin with it.
2007-10-24  Marek Habersack  <[email protected]>

	* System.Web.dll.sources: added
	System.Web.Configuration/FileMatchingInfo.cs

svn path=/trunk/mcs/; revision=88121
Marek Habersack vor 18 Jahren
Ursprung
Commit
511d26cdcc

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

@@ -1,3 +1,8 @@
+2007-10-24  Marek Habersack  <[email protected]>
+
+	* System.Web.dll.sources: added
+	System.Web.Configuration/FileMatchingInfo.cs
+
 2007-08-30  Marek Habersack  <[email protected]>
 
 	* System.Web.dll.sources: added MachineKeyRegistryStorage.cs

+ 10 - 0
mcs/class/System.Web/System.Web.Configuration/ChangeLog

@@ -1,3 +1,13 @@
+2007-10-24  Marek Habersack  <[email protected]>
+
+	* HandlerFactoryConfiguration.cs: exact path matching must be done
+	on the original string in PathMatches, not on the sliced one.
+
+	* FileMatchingInfo.cs: refactoring - this code used to live in
+	both 1.1 and 2.0 profiles. At the same time, fixe the way
+	MatchExact is created - the slash is prepended only if the path
+	doesn't begin with it.
+
 2007-10-15  Marek Habersack  <[email protected]>
 
 	* ModulesConfiguration.cs: load modules using

+ 69 - 0
mcs/class/System.Web/System.Web.Configuration/FileMatchingInfo.cs

@@ -0,0 +1,69 @@
+//
+// System.Web.Configuration.HttpHandlerAction
+//
+// Authors:
+//	Chris Toshok ([email protected])
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Text.RegularExpressions;
+
+namespace System.Web.Configuration 
+{
+	internal class FileMatchingInfo
+	{
+		public string MatchExact;
+		public string MatchExpr;
+
+		// If set, we can fast-path the patch with string.EndsWith (FMI.EndsWith)
+		public string EndsWith;
+		public Regex RegExp;
+		
+		public FileMatchingInfo (string s)
+		{
+			MatchExpr = s;
+			int len = s.Length;
+
+			if (len > 0) {
+				if (s[0] == '*' && (s.IndexOf ('*', 1) == -1))
+					EndsWith = s.Substring (1);
+
+				if (s.IndexOf ('*') == -1)
+					if (s [0] != '/')
+						MatchExact = "/" + s;
+			}
+				
+			if (MatchExpr != "*") {
+				string expr = MatchExpr.Replace(".", "\\.").Replace("?", "\\?").Replace("*", ".*");
+				if (expr.Length > 0 && expr [0] =='/')
+					expr = expr.Substring (1);
+
+				expr += "\\z";
+				RegExp = new Regex (expr);
+			}
+		}
+	}
+}

+ 2 - 32
mcs/class/System.Web/System.Web.Configuration/HandlerFactoryConfiguration.cs

@@ -35,37 +35,7 @@ using System.Collections;
 using System.Web.Util;
 using System.Text.RegularExpressions;
 
-namespace System.Web.Configuration {
-
-	class FileMatchingInfo {
-		public string MatchExact;
-		public string MatchExpr;
-
-		// If set, we can fast-path the patch with string.EndsWith (FMI.EndsWith)
-		public string EndsWith;
-		public Regex RegExp;
-		
-		public FileMatchingInfo (string s)
-		{
-			MatchExpr = s;
-
-			if (s[0] == '*' && (s.IndexOf ('*', 1) == -1))
-				EndsWith = s.Substring (1);
-
-			if (s.IndexOf ('*') == -1)
-				MatchExact = "/" + s;
-
-			if (MatchExpr != "*") {
-				string expr = MatchExpr.Replace(".", "\\.").Replace("?", "\\?").Replace("*", ".*");
-				if (expr.Length > 0 && expr [0] =='/')
-					expr = expr.Substring (1);
-
-				expr += "\\z";
-				RegExp = new Regex (expr);
-			}
-		}
-	}
-	
+namespace System.Web.Configuration {	
 	class HttpHandler {
 		// If `null', we are the "*" match
 		public string OriginalVerb;
@@ -131,7 +101,7 @@ namespace System.Web.Configuration {
 				FileMatchingInfo fm = files [j];
 
 				if (fm.MatchExact != null)
-					return fm.MatchExact.Length == p.Length && StrUtils.EndsWith (p, fm.MatchExact);
+					return fm.MatchExact.Length == orig.Length && StrUtils.EndsWith (orig, fm.MatchExact);
 					
 				if (fm.EndsWith != null)
 					return StrUtils.EndsWith (p, fm.EndsWith);

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

@@ -1,3 +1,9 @@
+2007-10-24  Marek Habersack  <[email protected]>
+
+	* HttpHandlerAction.cs: exact path matching must be done on the
+	original string in PathMatches, not on the sliced one. Fixes bug
+	#335669.
+
 2007-10-17  Marek Habersack  <[email protected]>
 
 	* WebConfigurationHost.cs: if running outside hosted environment,

+ 4 - 34
mcs/class/System.Web/System.Web.Configuration_2.0/HttpHandlerAction.cs

@@ -196,20 +196,19 @@ namespace System.Web.Configuration
 			string orig = p;
 			if (slash != -1)
 				p = p.Substring (slash);
-
+			
 			for (int j = Paths.Length; j > 0; ){
 				j--;
 				FileMatchingInfo fm = Paths [j];
-
+				
 				bool ignoreCase =
 #if TARGET_J2EE
 					true;
 #else
 					false;
-#endif
-
+#endif				
 				if (fm.MatchExact != null)
-					return fm.MatchExact.Length == p.Length && StrUtils.EndsWith (p, fm.MatchExact, ignoreCase);
+					return fm.MatchExact.Length == orig.Length && StrUtils.EndsWith (orig, fm.MatchExact, ignoreCase);
 					
 				if (fm.EndsWith != null)
 					return StrUtils.EndsWith (p, fm.EndsWith, ignoreCase);
@@ -237,35 +236,6 @@ namespace System.Web.Configuration
 			
 			return instance;
 		}
-
-		class FileMatchingInfo {
-			public string MatchExact;
-			public string MatchExpr;
-
-			// If set, we can fast-path the patch with string.EndsWith (FMI.EndsWith)
-			public string EndsWith;
-			public Regex RegExp;
-		
-			public FileMatchingInfo (string s)
-			{
-				MatchExpr = s;
-
-				if (s[0] == '*' && (s.IndexOf ('*', 1) == -1))
-					EndsWith = s.Substring (1);
-
-				if (s.IndexOf ('*') == -1)
-					MatchExact = "/" + s;
-
-				if (MatchExpr != "*") {
-					string expr = MatchExpr.Replace(".", "\\.").Replace("?", "\\?").Replace("*", ".*");
-					if (expr.Length > 0 && expr [0] =='/')
-						expr = expr.Substring (1);
-
-					expr += "\\z";
-					RegExp = new Regex (expr);
-				}
-			}
-		}
 #endregion
 
 	}

+ 1 - 0
mcs/class/System.Web/System.Web.dll.sources

@@ -91,6 +91,7 @@ System.Web.Configuration/CompilationConfigurationHandler.cs
 System.Web.Configuration/CompilerCollection.cs
 System.Web.Configuration/Compiler.cs
 System.Web.Configuration/CustomErrorsConfigHandler.cs
+System.Web.Configuration/FileMatchingInfo.cs
 System.Web.Configuration/FormsAuthPasswordFormat.cs
 System.Web.Configuration/FormsProtectionEnum.cs
 System.Web.Configuration/GlobalizationConfiguration.cs