Parcourir la source

2005-09-14 Sebastien Pouliot <[email protected]>

	* AttributeCollection.cs: Added LinkDemand for AspNetHostingPermission
	with Minimal level.
	* BaseParser.cs: Added LinkDemand and InheritanceDemand for 
	AspNetHostingPermission with Minimal level.
	* BasePartialCachingControl.cs: Added LinkDemand and InheritanceDemand
	for AspNetHostingPermission with Minimal level.
	* CompiledTemplateBuilder.cs: Added LinkDemand for 
	AspNetHostingPermission with Minimal level.
	* ConstructorNeedsTagAttribute.cs: Added LinkDemand for 
	AspNetHostingPermission with Minimal level.
	* ControlBuilderAttribute.cs: Added LinkDemand for 
	AspNetHostingPermission with Minimal level. Simplified Equals and 
	IsDefaultAttribute.
	* ControlBuilder.cs: Added LinkDemand and InheritanceDemand for 
	AspNetHostingPermission with Minimal level.
	* ControlCachePolicy.cs: Hided ctor and removed SupportsCaching setter
	* ControlCollection.cs: Added LinkDemand and InheritanceDemand for 
	AspNetHostingPermission with Minimal level. Fixed possible stack 
	overflow in Add* methods. Fixed CopyTo as we're not allocating the 
	array based on the number of items.
	* Control.cs: Added LinkDemand and InheritanceDemand for 
	AspNetHostingPermission with Minimal level. Fixed 2.0 signatures.
	* CssStyleCollection.cs: Added LinkDemand for AspNetHostingPermission 
	with Minimal level.
	* IStyleSheet.cs: Fixed parameter orders (2.0).


svn path=/trunk/mcs/; revision=50041
Sebastien Pouliot il y a 20 ans
Parent
commit
c1cc7616df

+ 4 - 3
mcs/class/System.Web/System.Web.UI/AttributeCollection.cs

@@ -6,8 +6,7 @@
 // 	Gonzalo Paniagua ([email protected])
 //
 // (C) 2002 Ximian, Inc. (http://www.ximian.com
-//
-
+// Copyright (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
@@ -29,12 +28,14 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
 using System.Collections;
 using System.Globalization;
+using System.Security.Permissions;
 
 namespace System.Web.UI {
 
+	// CAS - no InheritanceDemand here as the class is sealed
+	[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
 	public sealed class AttributeCollection
 	{
 		private StateBag bag;

+ 5 - 4
mcs/class/System.Web/System.Web.UI/BaseParser.cs

@@ -6,8 +6,7 @@
 //	Gonzalo Paniagua Javier ([email protected])
 //
 // (C) 2002 Ximian, Inc. (http://www.ximian.com)
-//
-
+// Copyright (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
@@ -29,16 +28,18 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
 using System.Collections;
 using System.IO;
-using System.Web;
+using System.Security.Permissions;
 using System.Web.Compilation;
 using System.Web.Configuration;
 using System.Web.Util;
 
 namespace System.Web.UI
 {
+	// CAS
+	[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+	[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
 	public class BaseParser
 	{
 		HttpContext context;

+ 6 - 4
mcs/class/System.Web/System.Web.UI/BasePartialCachingControl.cs

@@ -6,9 +6,7 @@
 //   Jackson Harper ([email protected])
 //
 // (C) 2003 Andreas Nahr
-// (C) 2004 Novell, Inc (http://www.novell.com)
-//
-
+// Copyright (C) 2004-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
@@ -30,14 +28,18 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
 using System.IO;
 using System.Text;
 using System.ComponentModel;
+using System.Security.Permissions;
 using System.Web.Caching;
 
 namespace System.Web.UI
 {
+	// CAS
+	[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+	[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+	// attributes
 	[ToolboxItem (false)]
 	public abstract class BasePartialCachingControl : Control
 	{

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

@@ -1,3 +1,31 @@
+2005-09-14  Sebastien Pouliot  <[email protected]> 
+
+	* AttributeCollection.cs: Added LinkDemand for AspNetHostingPermission
+	with Minimal level.
+	* BaseParser.cs: Added LinkDemand and InheritanceDemand for 
+	AspNetHostingPermission with Minimal level.
+	* BasePartialCachingControl.cs: Added LinkDemand and InheritanceDemand
+	for AspNetHostingPermission with Minimal level.
+	* CompiledTemplateBuilder.cs: Added LinkDemand for 
+	AspNetHostingPermission with Minimal level.
+	* ConstructorNeedsTagAttribute.cs: Added LinkDemand for 
+	AspNetHostingPermission with Minimal level.
+	* ControlBuilderAttribute.cs: Added LinkDemand for 
+	AspNetHostingPermission with Minimal level. Simplified Equals and 
+	IsDefaultAttribute.
+	* ControlBuilder.cs: Added LinkDemand and InheritanceDemand for 
+	AspNetHostingPermission with Minimal level.
+	* ControlCachePolicy.cs: Hided ctor and removed SupportsCaching setter
+	* ControlCollection.cs: Added LinkDemand and InheritanceDemand for 
+	AspNetHostingPermission with Minimal level. Fixed possible stack 
+	overflow in Add* methods. Fixed CopyTo as we're not allocating the 
+	array based on the number of items.
+	* Control.cs: Added LinkDemand and InheritanceDemand for 
+	AspNetHostingPermission with Minimal level. Fixed 2.0 signatures.
+	* CssStyleCollection.cs: Added LinkDemand for AspNetHostingPermission 
+	with Minimal level.
+	* IStyleSheet.cs: Fixed parameter orders (2.0).
+
 2005-09-10 Gonzalo Paniagua Javier <[email protected]>
 
 	* TemplateParser.cs: default VS 2005 pages are compiled fine now.

+ 5 - 0
mcs/class/System.Web/System.Web.UI/CompiledTemplateBuilder.cs

@@ -5,6 +5,7 @@
 //	Gonzalo Paniagua Javier ([email protected])
 //
 // (C) 2002 Ximian, Inc (http://www.ximian.com)
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
 //
 // This is used in the generated C# code from MS and xsp does the same.
 // It just seems to be a container implementing an ITemplate interface.
@@ -30,8 +31,12 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System.Security.Permissions;
+
 namespace System.Web.UI {
 
+// CAS - no InheritanceDemand here as the class is sealed
+[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
 public sealed class CompiledTemplateBuilder : ITemplate
 {
 	private BuildTemplateMethod templateMethod;

+ 5 - 2
mcs/class/System.Web/System.Web.UI/ConstructorNeedsTagAttribute.cs

@@ -4,7 +4,7 @@
 // Duncan Mak  ([email protected])
 //
 // (C) Ximian, Inc.
-
+// Copyright (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
@@ -26,10 +26,13 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
+using System.Security.Permissions;
 
 namespace System.Web.UI {
 
+	// CAS - no InheritanceDemand here as the class is sealed
+	[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+	// attributes
 	[AttributeUsage (AttributeTargets.Class)]
 	public sealed class ConstructorNeedsTagAttribute : Attribute
 	{

+ 6 - 10
mcs/class/System.Web/System.Web.UI/Control.cs

@@ -36,11 +36,11 @@
 // This will provide extra information when trace is enabled. Might be too verbose.
 #define MONO_TRACE
 
-using System;
 using System.Collections;
 using System.ComponentModel;
 using System.ComponentModel.Design;
 using System.ComponentModel.Design.Serialization;
+using System.Security.Permissions;
 using System.Web;
 using System.Web.Util;
 #if NET_2_0
@@ -50,6 +50,10 @@ using System.IO;
 
 namespace System.Web.UI
 {
+	// CAS
+	[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+	[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+	// attributes
 	[DefaultProperty ("ID"), DesignerCategory ("Code"), ToolboxItemFilter ("System.Web.UI", ToolboxItemFilterType.Require)]
 	[ToolboxItem ("System.Web.UI.Design.WebControlToolboxItem, " + Consts.AssemblySystem_Design)]
 	[Designer ("System.Web.UI.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
@@ -1406,15 +1410,7 @@ namespace System.Web.UI
 			set { skinId = value; }
 		}
 		
-		/* This shouldnt be in 2.0, and I can't find it in 1.1
-		 * either, so leaving alone for now.
-		 */
-		protected string GetWebResourceUrl (string resourceName)
-		{
-			return Page.ClientScript.GetWebResourceUrl (GetType(), resourceName); 
-		} 
-
-		string IUrlResolutionService.ResolveClientUrl (string url)
+		string ResolveClientUrl (string url)
 		{
 			throw new NotImplementedException ();               
 		}

+ 5 - 4
mcs/class/System.Web/System.Web.UI/ControlBuilder.cs

@@ -6,8 +6,7 @@
 // 	Gonzalo Paniagua Javier ([email protected])
 //
 // (C) 2002, 2003 Ximian, Inc. (http://www.ximian.com)
-//
-
+// Copyright (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
@@ -29,15 +28,17 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
 using System.Collections;
 using System.CodeDom;
 using System.Reflection;
-using System.Web;
+using System.Security.Permissions;
 using System.Web.Compilation;
 
 namespace System.Web.UI {
 
+	// CAS
+	[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+	[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
 	public class ControlBuilder
 	{
 		internal static BindingFlags flagsNoCase = BindingFlags.Public |

+ 10 - 5
mcs/class/System.Web/System.Web.UI/ControlBuilderAttribute.cs

@@ -4,9 +4,10 @@
 // Authors:
 // 	Duncan Mak  ([email protected])
 // 	Gonzalo Paniagua Javier ([email protected])
+//	Sebastien Pouliot  <[email protected]>
 //
 // (C) 2002 Ximian, Inc. (http://www.ximian.com)
-
+// Copyright (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
@@ -28,10 +29,13 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
+using System.Security.Permissions;
 
 namespace System.Web.UI {
 
+	// CAS - no InheritanceDemand here as the class is sealed
+	[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+	// attributes
 	[AttributeUsage (AttributeTargets.Class)]
 	public sealed class ControlBuilderAttribute : Attribute
 	{
@@ -49,9 +53,10 @@ namespace System.Web.UI {
 
 		public override bool Equals (object obj)
 		{
-			if (!(obj is ControlBuilderAttribute))
+			ControlBuilderAttribute cba = (obj as ControlBuilderAttribute);
+			if (cba == null)
 				return false;
-			return ((ControlBuilderAttribute) obj).builderType == builderType;
+			return (cba.builderType == builderType);
 		}
 
 		public override int GetHashCode ()
@@ -61,7 +66,7 @@ namespace System.Web.UI {
 
 		public override bool IsDefaultAttribute ()
 		{
-			return Equals (Default);
+			return (builderType == null);
 		}
 	}
 }

+ 7 - 5
mcs/class/System.Web/System.Web.UI/ControlCachePolicy.cs

@@ -27,13 +27,18 @@
 //
 
 #if NET_2_0
-using System.Web;
+
 using System.Web.Caching;
 
 namespace System.Web.UI
 {
+	[MonoTODO ("only stubbed")]
 	public sealed class ControlCachePolicy
 	{
+		internal ControlCachePolicy ()
+		{
+		}
+
 		public bool Cached 
 		{
 			get {
@@ -69,9 +74,6 @@ namespace System.Web.UI
 			get {
 				throw new NotImplementedException ();
 			}
-			set {
-				throw new NotImplementedException ();
-			}
 		}
 
 		public string VaryByControl 
@@ -107,4 +109,4 @@ namespace System.Web.UI
 		}
 	}
 }
-#endif
+#endif

+ 29 - 7
mcs/class/System.Web/System.Web.UI/ControlCollection.cs

@@ -5,9 +5,7 @@
 //	Duncan Mak  ([email protected])
 //	Gonzalo Paniagua Javier ([email protected])
 //
-// Copyright (c) 2002-2004 Novell, Inc. (http://www.novell.com)
-//
-
+// Copyright (c) 2002-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
@@ -29,11 +27,14 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
 using System.Collections;
+using System.Security.Permissions;
 
 namespace System.Web.UI {
 
+	// CAS
+	[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+	[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
 	public class ControlCollection : ICollection, IEnumerable
 	{
 		Control owner;
@@ -97,7 +98,10 @@ namespace System.Web.UI {
 				throw new ArgumentNullException ();
 
 			if (readOnly)
-				throw new HttpException ();
+				throw new HttpException (Locale.GetText ("Collection is read-only."));
+
+			if (Object.ReferenceEquals (owner, child))
+				throw new HttpException (Locale.GetText ("Cannot add collection's owner."));
 
 			EnsureControls ();
 			version++;
@@ -114,7 +118,10 @@ namespace System.Web.UI {
 				throw new ArgumentOutOfRangeException ();
 
 			if (readOnly)
-				throw new HttpException ();
+				throw new HttpException (Locale.GetText ("Collection is read-only."));
+
+			if (Object.ReferenceEquals (owner, child))
+				throw new HttpException (Locale.GetText ("Cannot add collection's owner."));
 
 			if (index == -1) {
 				Add (child);
@@ -153,7 +160,22 @@ namespace System.Web.UI {
 			if (controls == null)
 				return;
 
-			controls.CopyTo (array, index);
+			// can't use controls.CopyTo (array, index);
+			// as we do not allocate it based on the true 
+			// numbers of items we have in the collection
+			// so we must re-implement Array.CopyTo :(
+
+			if (array == null)
+				throw new ArgumentNullException ("array");
+			if (index + count > array.GetLowerBound (0) + array.GetLength (0))
+				throw new ArgumentException ();
+			if (array.Rank > 1)
+				throw new RankException (Locale.GetText ("Only single dimension arrays are supported."));
+			if (index < 0)
+				throw new ArgumentOutOfRangeException ("index", Locale.GetText ("Value has to be >= 0."));
+
+			for (int i=0; i < count; i++)
+				array.SetValue (controls [i], i);
 		}
 
 		public IEnumerator GetEnumerator ()

+ 3 - 0
mcs/class/System.Web/System.Web.UI/CssStyleCollection.cs

@@ -30,10 +30,13 @@
 
 using System.IO;
 using System.Collections;
+using System.Security.Permissions;
 using System.Text;
 
 namespace System.Web.UI {
 
+	// CAS - no InheritanceDemand here as the class is sealed
+	[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
 	public sealed class CssStyleCollection
 	{
 		private StateBag bag;

+ 3 - 4
mcs/class/System.Web/System.Web.UI/IStyleSheet.cs

@@ -4,8 +4,7 @@
 // Authors:
 //      Sanjay Gupta ([email protected])
 //
-// (C) 2004 Novell, Inc (http://www.novell.com)
-//
+// Copyright (C) 2004-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
@@ -29,14 +28,14 @@
 
 
 #if NET_2_0
-using System;
+
 using System.Web.UI.WebControls;
 
 namespace System.Web.UI
 {
 	public interface IStyleSheet
 	{
-		void CreateStyleRule (Style style, string selection, IUrlResolutionService urlResolver);
+		void CreateStyleRule (Style style, IUrlResolutionService urlResolver, string selection);
 		void RegisterStyle (Style style, IUrlResolutionService urlResolver);
 	}
 }