소스 검색

2009-08-24 Marek Habersack <[email protected]>

	* PageParser.cs: 2.0 profile takes advantage of the inputFile
	parameter to GetCompiledPageInstance. A check is made whether the
	file pointed to by this parameter is inside the application's
	virtual path and if not, the compilation request is assumed to
	refer to a fake location. Part of fix for bug #463813

2009-08-24  Marek Habersack  <[email protected]>

	* PageBuildProvider.cs: MapPath now takes a VirtualPath
	instance. Part of fix for bug #463813

	* BuildManager.cs: public APIs which take virtual path strings as
	their parameters got internal counterparts accepting a VirtualPath
	instance in place of string. Part of fix for bug #463813

	* GenericBuildProvider.cs:
	MapPath now takes a VirtualPath instance. Part of fix for bug
	#463813

2009-08-24  Marek Habersack  <[email protected]>

	* SoapDocumentationHandler.cs: get rid of the ugly fake virtual
	path hack when creating the helper page. Part of fix for bug
	#463813

2009-08-24  Marek Habersack  <[email protected]>

	* VirtualPath.cs: Added new constructor which takes virtual and
	physical paths as well as a boolean marking the instance as
	referring to a fake location. Part of fix for bug #463813

svn path=/trunk/mcs/; revision=140548
Marek Habersack 16 년 전
부모
커밋
b6969f355f

+ 6 - 0
mcs/class/System.Web.Services/System.Web.Services.Protocols/ChangeLog

@@ -1,3 +1,9 @@
+2009-08-24  Marek Habersack  <[email protected]>
+
+	* SoapDocumentationHandler.cs: get rid of the ugly fake virtual
+	path hack when creating the helper page. Part of fix for bug
+	#463813
+
 2009-07-23 Gonzalo Paniagua Javier <[email protected]>
 
 	* LogicalMethodInfo.cs: add CacheDuration property.

+ 0 - 12
mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapDocumentationHandler.cs

@@ -105,19 +105,7 @@ namespace System.Web.Services.Protocols
 				throw new InvalidOperationException ("Documentation page '" + physPath + "' not found");
 #endif
 
-#if NET_2_0 && !TARGET_JVM
-			// Since BuildManager expects the virtualPath to be mappable into the
-			// application virtual root directory and the WSDL help generator possibly
-			// lives outside the location (by default in $prefix/etc/mono/2.0/), we need
-			// to use a fake virtual path which will be recognized by the page builder
-			// and processed accordingly.
-			// The fake virtual path prefix is defined in
-			// BuildManager.FAKE_VIRTUAL_PATH_PREFIX constant
-			_pageHandler = BuildManager.CreateInstanceFromVirtualPath ("/@@MonoFakeVirtualPath@@" + physPath, typeof (IHttpHandler)) as IHttpHandler;
-#else
 			_pageHandler = PageParser.GetCompiledPageInstance (vpath, physPath, context);
-#endif
-				
 		}
 
 		internal IHttpHandler PageHandler {

+ 28 - 11
mcs/class/System.Web/System.Web.Compilation/BuildManager.cs

@@ -466,6 +466,11 @@ namespace System.Web.Compilation {
 		}
 		
 		public static object CreateInstanceFromVirtualPath (string virtualPath, Type requiredBaseType)
+		{
+			return CreateInstanceFromVirtualPath (GetAbsoluteVirtualPath (virtualPath), requiredBaseType);
+		}
+
+		internal static object CreateInstanceFromVirtualPath (VirtualPath virtualPath, Type requiredBaseType)
 		{
 			if (requiredBaseType == null)
 				throw new NullReferenceException (); // This is what MS does, but
@@ -481,7 +486,7 @@ namespace System.Web.Compilation {
 
 			return Activator.CreateInstance (type, null);
 		}
-
+		
 		static void DescribeCompilationError (string format, CompilationException ex, params object[] parms)
 		{
 			StringBuilder sb = new StringBuilder ();
@@ -722,8 +727,12 @@ namespace System.Web.Compilation {
 
 		public static Assembly GetCompiledAssembly (string virtualPath)
 		{
-			VirtualPath vp = GetAbsoluteVirtualPath (virtualPath);
-			string vpabsolute = vp.Absolute;
+			return GetCompiledAssembly (GetAbsoluteVirtualPath (virtualPath));
+		}
+
+		internal static Assembly GetCompiledAssembly (VirtualPath virtualPath)
+		{
+			string vpabsolute = virtualPath.Absolute;
 			if (is_precompiled) {
 				Type type = GetPrecompiledType (vpabsolute);
 				if (type != null)
@@ -733,18 +742,22 @@ namespace System.Web.Compilation {
 			if (bmci != null)
 				return bmci.BuiltAssembly;
 
-			Build (vp);
+			Build (virtualPath);
 			bmci = GetCachedItem (vpabsolute);
 			if (bmci != null)
 				return bmci.BuiltAssembly;
 			
 			return null;
 		}
-
+		
 		public static Type GetCompiledType (string virtualPath)
 		{
-			VirtualPath vp = GetAbsoluteVirtualPath (virtualPath);
-			string vpabsolute = vp.Absolute;
+			return GetCompiledType (GetAbsoluteVirtualPath (virtualPath));
+		}
+
+		internal static Type GetCompiledType (VirtualPath virtualPath)
+		{
+			string vpabsolute = virtualPath.Absolute;
 			if (is_precompiled) {
 				Type type = GetPrecompiledType (vpabsolute);
 				if (type != null)
@@ -756,7 +769,7 @@ namespace System.Web.Compilation {
 				return bmci.Type;
 			}
 
-			Build (vp);
+			Build (virtualPath);
 			bmci = GetCachedItem (vpabsolute);
 			if (bmci != null) {
 				ReferenceAssemblyInCompilation (bmci);
@@ -768,13 +781,17 @@ namespace System.Web.Compilation {
 
 		public static string GetCompiledCustomString (string virtualPath)
 		{
-			VirtualPath vp = GetAbsoluteVirtualPath (virtualPath);
-			string vpabsolute = vp.Absolute;
+			return GetCompiledCustomString (GetAbsoluteVirtualPath (virtualPath));
+		}
+	
+		internal static string GetCompiledCustomString (VirtualPath virtualPath) 
+		{
+			string vpabsolute = virtualPath.Absolute;
 			BuildManagerCacheItem bmci = GetCachedItem (vpabsolute);
 			if (bmci != null)
 				return bmci.CompiledCustomString;
 			
-			Build (vp);
+			Build (virtualPath);
 			bmci = GetCachedItem (vpabsolute);
 			if (bmci != null)
 				return bmci.CompiledCustomString;

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

@@ -1,11 +1,20 @@
 2009-08-24  Marek Habersack  <[email protected]>
 
+	* PageBuildProvider.cs: MapPath now takes a VirtualPath
+	instance. Part of fix for bug #463813
+
+	* BuildManager.cs: public APIs which take virtual path strings as
+	their parameters got internal counterparts accepting a VirtualPath
+	instance in place of string. Part of fix for bug #463813
+
 	* TemplateBuildProvider.cs: ExtractDependencies checks if the
 	input has already been parsed/compiled and, if yes, adds
 	dependencies from the TemplateParser to the list of the ones
 	extracted locally. Fixes bug #377915
 
 	* GenericBuildProvider.cs: added Parsed property.
+	MapPath now takes a VirtualPath instance. Part of fix for bug
+	#463813
 
 2009-08-21  Marek Habersack  <[email protected]>
 

+ 2 - 2
mcs/class/System.Web/System.Web.Compilation/GenericBuildProvider.cs

@@ -63,7 +63,7 @@ namespace System.Web.Compilation
 		protected abstract AspGenerator CreateAspGenerator (TParser parser);
 		protected abstract List <string> GetReferencedAssemblies (TParser parser);
 
-		protected virtual string MapPath (string virtualPath)
+		protected virtual string MapPath (VirtualPath virtualPath)
 		{
 			HttpContext ctx = HttpContext.Current;
 			HttpRequest req = ctx != null ? ctx.Request : null;
@@ -84,7 +84,7 @@ namespace System.Web.Compilation
 			if (!IsDirectoryBuilder) {
 				AspGenerator generator = CreateAspGenerator (parser);
 				if (_reader != null)
-					generator.Parse (_reader, MapPath (VirtualPath), true);
+					generator.Parse (_reader, MapPath (VirtualPathInternal), true);
 				else
 					generator.Parse ();
 			}

+ 3 - 3
mcs/class/System.Web/System.Web.Compilation/PageBuildProvider.cs

@@ -49,11 +49,11 @@ namespace System.Web.Compilation {
 		{
 		}
 
-		protected override string MapPath (string virtualPath)
+		protected override string MapPath (VirtualPath virtualPath)
 		{
 			// We need this hack to support out-of-application wsdl helpers
-			if (StrUtils.StartsWith (virtualPath, BuildManager.FAKE_VIRTUAL_PATH_PREFIX))
-				return virtualPath.Substring (BuildManager.FAKE_VIRTUAL_PATH_PREFIX.Length);
+			if (virtualPath.IsFake)
+				return virtualPath.PhysicalPath;
 
 			return base.MapPath (virtualPath);
 		}               

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

@@ -1,3 +1,11 @@
+2009-08-24  Marek Habersack  <[email protected]>
+
+	* PageParser.cs: 2.0 profile takes advantage of the inputFile
+	parameter to GetCompiledPageInstance. A check is made whether the
+	file pointed to by this parameter is inside the application's
+	virtual path and if not, the compilation request is assumed to
+	refer to a fake location. Part of fix for bug #463813
+
 2009-08-18  Marek Habersack  <[email protected]>
 
 	* ControlBuilder.cs: Location property makes a copy of assigned

+ 6 - 1
mcs/class/System.Web/System.Web.UI/PageParser.cs

@@ -153,7 +153,12 @@ namespace System.Web.UI
 								    HttpContext context)
 		{
 #if NET_2_0
-			return BuildManager.CreateInstanceFromVirtualPath (virtualPath, typeof (IHttpHandler)) as IHttpHandler;
+			bool isFake = false;
+
+			if (!String.IsNullOrEmpty (inputFile))
+				isFake = !inputFile.StartsWith (HttpRuntime.AppDomainAppPath);
+			
+			return BuildManager.CreateInstanceFromVirtualPath (new VirtualPath (virtualPath, inputFile, isFake), typeof (IHttpHandler)) as IHttpHandler;
 #else
 			PageParser pp = new PageParser (virtualPath, inputFile, context);
 			IHttpHandler h = (IHttpHandler) pp.GetCompiledInstance ();

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

@@ -1,3 +1,9 @@
+2009-08-24  Marek Habersack  <[email protected]>
+
+	* VirtualPath.cs: Added new constructor which takes virtual and
+	physical paths as well as a boolean marking the instance as
+	referring to a fake location. Part of fix for bug #463813
+
 2009-07-28 Gonzalo Paniagua Javier <[email protected]>
 
 	* HttpApplicationFactory.cs: allow subclasses of EventHandler for

+ 18 - 10
mcs/class/System.Web/System.Web/VirtualPath.cs

@@ -181,13 +181,27 @@ namespace System.Web
 		}
 				
 		public VirtualPath (string vpath)
+			: this (vpath, null, false)
+		{
+		}
+		
+		public VirtualPath (string vpath, string baseVirtualDir)
+			: this (vpath, null, false)
+		{
+			CurrentRequestDirectory = baseVirtualDir;
+		}
+
+		public VirtualPath (string vpath, string physicalPath, bool isFake)
 		{
 			IsRooted = VirtualPathUtility.IsRooted (vpath);
 			IsAbsolute = VirtualPathUtility.IsAbsolute (vpath);
 			IsAppRelative = VirtualPathUtility.IsAppRelative (vpath);
-
-			if (StrUtils.StartsWith (vpath, BuildManager.FAKE_VIRTUAL_PATH_PREFIX)) {
-				_physicalPath = vpath.Substring (BuildManager.FAKE_VIRTUAL_PATH_PREFIX.Length);
+			
+			if (isFake) {
+				if (String.IsNullOrEmpty (physicalPath))
+					throw new ArgumentException ("physicalPath");
+				
+				_physicalPath = physicalPath;
 				Original = "~/" + Path.GetFileName (_physicalPath);
 				IsFake = true;
 			} else {
@@ -195,12 +209,6 @@ namespace System.Web
 				IsFake = false;
 			}
 		}
-
-		public VirtualPath (string vpath, string baseVirtualDir)
-			: this (vpath)
-		{
-			CurrentRequestDirectory = baseVirtualDir;
-		}
 		
 		public bool StartsWith (string s)
 		{
@@ -235,7 +243,7 @@ namespace System.Web
 				return GetType ().ToString ();
 
 			if (IsFake)
-				ret += " [fake]";
+				ret += " [fake: " + PhysicalPath + "]";
 			
 			return ret;
 		}