瀏覽代碼

2003-07-03 Gonzalo Paniagua Javier <[email protected]>

	* MailAddress.cs: return null instead of exception when the address is
	empty.

	* MailAddressCollection.cs: ignore null addresses.
	* SmtpMail.cs: add the exception we get as inner exception so we know
	where the error is.

	Fixes bug #45746.

svn path=/trunk/mcs/; revision=15886
Gonzalo Paniagua Javier 22 年之前
父節點
當前提交
81f6e15911

+ 11 - 0
mcs/class/System.Web/System.Web.Mail/ChangeLog

@@ -1,3 +1,14 @@
+2003-07-03  Gonzalo Paniagua Javier <[email protected]>
+
+	* MailAddress.cs: return null instead of exception when the address is
+	empty.
+	
+	* MailAddressCollection.cs: ignore null addresses.
+	* SmtpMail.cs: add the exception we get as inner exception so we know
+	where the error is.
+
+	Fixes bug #45746.
+
 2003-03-24  Per Arneng <[email protected]>
 	* MailUtil: Added for some functions that didnt fit in other classes
 	

+ 3 - 0
mcs/class/System.Web/System.Web.Mail/MailAddress.cs

@@ -47,6 +47,9 @@ namespace System.Web.Mail {
 	}
 
 	public static MailAddress Parse( string str ) {
+	    if (str == null || str.Trim () == "")
+	    	return null;
+
 	    MailAddress addr = new MailAddress();
 	    string address = null;
 	    string nameString = null;

+ 5 - 1
mcs/class/System.Web/System.Web.Mail/MailAddressCollection.cs

@@ -53,7 +53,11 @@ namespace System.Web.Mail {
 	    string[] parts = str.Split( new char[] { ',' , ';' } );
 	    
 	    foreach( string part in parts ) {
-		list.Add( MailAddress.Parse( part ) );
+	    	MailAddress add = MailAddress.Parse (part);
+		if (add == null)
+			continue;
+
+		list.Add (add);
 	    }
 	
 	    return list;

+ 4 - 4
mcs/class/System.Web/System.Web.Mail/SmtpMail.cs

@@ -54,19 +54,19 @@ namespace System.Web.Mail
 			// .NET sdk throws HttpException
 			// for some reason so to be compatible
 			// we have to do it to :(
-			throw new HttpException (ex.Message);
+			throw new HttpException (ex.Message, ex);
 		    
 		    } catch (IOException ex) {
 			
-			throw new HttpException (ex.Message);
+			throw new HttpException (ex.Message, ex);
 			
 		    } catch (FormatException ex) {
 			
-			throw new HttpException (ex.Message);
+			throw new HttpException (ex.Message, ex);
 		    
 		    } catch (SocketException ex) {
 			
-			throw new HttpException (ex.Message);
+			throw new HttpException (ex.Message, ex);
 			
 		    }