Browse Source

2009-06-03 Marek Habersack <[email protected]>

	* MonoSettingsSection.cs: added new property,
	verificationCompatibility, which serves the same purpose as the
	registry key described in http://support.microsoft.com/kb/932552
	(when set to 1 it turns off virtual path validity
	verification). Fixes bug #509163

2009-06-03  Marek Habersack  <[email protected]>

	* VirtualPathUtility.cs: IsValidVirtualPath now checks the value
	of the
	HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\VerificationCompatibility
	registry key when running on Windows and also consults the
	mono-specific system.web/monoSettings configuration section to see
	what is the verificationCompatibility property set to. If either
	of the two is set to 1, Mono will not verify the validity of
	the current request's path. Fixes bug #509163

svn path=/trunk/mcs/; revision=135328
Marek Habersack 16 năm trước cách đây
mục cha
commit
3346c35db8

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

@@ -1,3 +1,11 @@
+2009-06-03  Marek Habersack  <[email protected]>
+
+	* MonoSettingsSection.cs: added new property,
+	verificationCompatibility, which serves the same purpose as the
+	registry key described in http://support.microsoft.com/kb/932552
+	(when set to 1 it turns off virtual path validity
+	verification). Fixes bug #509163
+
 2009-05-14  Marek Habersack  <[email protected]>
 
 	* HttpHandlersSection.cs: if we're matching a default handler,

+ 9 - 0
mcs/class/System.Web/System.Web.Configuration_2.0/MonoSettingsSection.cs

@@ -40,16 +40,19 @@ namespace System.Web.Configuration
 		static ConfigurationPropertyCollection properties;
 		static ConfigurationProperty compilersCompatibilityProp;
 		static ConfigurationProperty useCompilersCompatibilityProp;
+		static ConfigurationProperty verificationCompatibilityProp;
 		
 		static MonoSettingsSection ()
 		{
 			compilersCompatibilityProp = new ConfigurationProperty ("compilersCompatibility", typeof (CompilerCollection), null, null, PropertyHelper.DefaultValidator,
 										ConfigurationPropertyOptions.None);
 			useCompilersCompatibilityProp = new ConfigurationProperty ("useCompilersCompatibility", typeof (bool), true);
+			verificationCompatibilityProp = new ConfigurationProperty ("verificationCompatibility", typeof (int), 0);
 			
 			properties = new ConfigurationPropertyCollection ();
 			properties.Add (compilersCompatibilityProp);
 			properties.Add (useCompilersCompatibilityProp);
+			properties.Add (verificationCompatibilityProp);
 		}
 
 		[ConfigurationProperty ("compilersCompatibility")]
@@ -62,6 +65,12 @@ namespace System.Web.Configuration
                         get { return (bool) base [useCompilersCompatibilityProp]; }
                         set { base [useCompilersCompatibilityProp] = value; }
                 }
+
+		[ConfigurationProperty ("verificationCompatibility", DefaultValue = "0")]
+                public int VerificationCompatibility {
+                        get { return (int) base [verificationCompatibilityProp]; }
+                        set { base [verificationCompatibilityProp] = value; }
+                }
 		
 		protected override ConfigurationPropertyCollection Properties {
                         get { return properties; }

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

@@ -1,5 +1,14 @@
 2009-06-03  Marek Habersack  <[email protected]>
 
+	* VirtualPathUtility.cs: IsValidVirtualPath now checks the value
+	of the
+	HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\VerificationCompatibility
+	registry key when running on Windows and also consults the
+	mono-specific system.web/monoSettings configuration section to see
+	what is the verificationCompatibility property set to. If either
+	of the two is set to 1, Mono will not verify the validity of
+	the current request's path. Fixes bug #509163
+
 	* HttpApplicationFactory.cs: OnFileChanged must check whether the
 	modified location is a directory before it decides to ignore it
 	when watcher's filter is "?eb.?config". Fixes bug #509450 (see

+ 27 - 2
mcs/class/System.Web/System.Web/VirtualPathUtility.cs

@@ -29,9 +29,11 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-
+using System.Collections.Specialized;
+using System.Web.Configuration;
 using System.Web.Util;
 using System.Text;
+using Microsoft.Win32;
 
 namespace System.Web {
 
@@ -455,12 +457,35 @@ namespace System.Web {
 		}
 
 		// See: http://support.microsoft.com/kb/932552
+		// See: https://bugzilla.novell.com/show_bug.cgi?id=509163
 		static readonly char[] invalidVirtualPathChars = {':', '*'};
+		static readonly string aspNetVerificationKey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ASP.NET";
 		internal static bool IsValidVirtualPath (string path)
 		{
 			if (path == null)
 				return false;
-			
+
+#if NET_2_0
+			bool doValidate = true;
+			if (HttpRuntime.RunningOnWindows) {
+				try {
+					object v = Registry.GetValue (aspNetVerificationKey, "VerificationCompatibility", null);
+					if (v != null && v is int)
+						doValidate = (int)v != 1;
+				} catch {
+					// ignore
+				}
+			}
+
+			if (doValidate) {
+				var monoSettings = WebConfigurationManager.GetWebApplicationSection ("system.web/monoSettings") as MonoSettingsSection;
+				if (monoSettings != null)
+					doValidate = monoSettings.VerificationCompatibility != 1;
+			}
+
+			if (!doValidate)
+				return true;
+#endif
 			return path.IndexOfAny (invalidVirtualPathChars) == -1;
 		}
 	}