Explorar el Código

2002-05-09 Lawrence Pit <[email protected]>

	* fixed bug in IPEndPoint.Equals method
	* fixed bug in IPAddress.Parse method
	* fixed bug in IPAddress.SwapLong method
	* fixed several bugs in Cookie.cs

svn path=/trunk/mcs/; revision=4435
Lawrence Pit hace 23 años
padre
commit
786a3bc57b

+ 7 - 0
mcs/class/System/System.Net/ChangeLog

@@ -1,3 +1,10 @@
+2002-05-09  Lawrence Pit <[email protected]>
+
+	* fixed bug in IPEndPoint.Equals method
+	* fixed bug in IPAddress.Parse method
+	* fixed bug in IPAddress.SwapLong method
+	* fixed several bugs in Cookie.cs
+
 2002-05-06  Lawrence Pit <[email protected]>
 
 	* WebRequest.cs: added

+ 4 - 5
mcs/class/System/System.Net/Cookie.cs

@@ -32,7 +32,7 @@ namespace System.Net {
 		private string val;
 		private int version;
 		
-		private static char [] reservedCharsName = new char [] {'=', ';', ',', '\n', '\r', '\t'};
+		private static char [] reservedCharsName = new char [] {' ', '=', ';', ',', '\n', '\r', '\t'};
 		private static char [] reservedCharsValue = new char [] {';', ','};
 		private static char [] portSeparators = new char [] {'"', ','};
                 private static string tspecials = "()<>@,;:\\\"/[]?={} \t";   // from RFC 2965, 2068
@@ -107,14 +107,13 @@ namespace System.Net {
 			get { return name; }
 			set { 
 				if (value == null || value.Length == 0) {
-					name = String.Empty;
-					return;
+					throw new CookieException ("Name cannot be empty");
 				}			
 				
 				if (value [0] == '$' || value.IndexOfAny (reservedCharsName) != -1) {
 					// see CookieTest, according to MS implementation
 					// the name value changes even though it's incorrect
-					name = value;
+					name = String.Empty;
 					throw new CookieException ("Name contains invalid characters");
 				}
 					
@@ -204,7 +203,7 @@ namespace System.Net {
 			       String.Compare (this.name, c.name, true) == 0 &&
 			       String.Compare (this.val, c.val, false) == 0 &&
 			       String.Compare (this.path, c.path, false) == 0 &&
-			       String.Compare (this.domain, c.domain) == 0 &&
+			       String.Compare (this.domain, c.domain, true) == 0 &&
 			       this.version == c.version;
 		}
 		

+ 6 - 6
mcs/class/System/System.Net/IPAddress.cs

@@ -54,7 +54,7 @@ namespace System.Net {
 			byte b5 = (byte) ((number >> 16) & 0xFF);
 			byte b6 = (byte) ((number >> 8) & 0xFF);
 			byte b7 = (byte) (number & 0xFF);
-			return b0 + (b1 << 8) + (b2 << 16) + (b3 << 24) + (b4 << 32) + (b5 << 40) + (b6 << 48) + (b7 << 56);
+			return (long) b0 + ((long) b1 << 8) + ((long) b2 << 16) + ((long) b3 << 24) + ((long) b4 << 32) + ((long) b5 << 40) + ((long) b6 << 48) + ((long) b7 << 56);
 		}
 
 		public static short HostToNetworkOrder(short host) {
@@ -146,12 +146,11 @@ namespace System.Net {
 				throw new FormatException ("the string is not a valid ip");
 
 
-			int a = 0;
+			long a = 0;
 			string [] ips = ip.Split (new char [] {'.'});
 			// Make the number in network order
 			for (int i = ips.Length - 1; i >= 0; i--)
 				a = (a << 8) |  (Byte.Parse(ips [i]));
-			
 			return (new IPAddress (a));
 		}
 		
@@ -160,10 +159,11 @@ namespace System.Net {
 				return address;
 			}
 			set {
-				// FIXME: Temporarily disabled as a workaround for bug #23547
-				/*if (value < 0 || value > 0x00000000FFFFFFFF)
+				/* no need to do this test, ms.net accepts any value.
+				if (value < 0 || value > 0x00000000FFFFFFFF)
 					throw new ArgumentOutOfRangeException (
-						"the address must be between 0 and 0xFFFFFFFF");*/
+						"the address must be between 0 and 0xFFFFFFFF");
+				*/
 
 				address = value;
 			}

+ 8 - 9
mcs/class/System/System.Net/IPEndPoint.cs

@@ -13,6 +13,9 @@ namespace System.Net {
 	[Serializable]
 	public class IPEndPoint : EndPoint {
 
+		private IPAddress address;
+		private int port;
+
 		public const int MaxPort = 65535;
 		public const int MinPort = 0;
 		
@@ -29,10 +32,9 @@ namespace System.Net {
 		{
 		}
 
-		private IPAddress address;
 		public IPAddress Address {
 			get {
-				return(address);
+				return (address);
 			}
 			set {
 				address=value;
@@ -45,7 +47,6 @@ namespace System.Net {
 			}
 		}
 
-		private int port;
 		public int Port {
 			get {
 				return port;
@@ -114,12 +115,10 @@ namespace System.Net {
 
 		public override bool Equals (Object obj)
 		{
-			if (obj is System.Net.IPEndPoint) {
-				return ( ((IPEndPoint) obj).port == port &&
-					 ((IPEndPoint) obj).address == address);
-			}
-
-			return false;
+			IPEndPoint p = obj as IPEndPoint;
+			return p != null && 
+			       p.port == port && 
+			       p.address.Equals (address);
 		}
 
 		public override int GetHashCode ()