Fix dot stuffing in SmtpClient
[mono.git] / mcs / class / System / System.Net.Mail / SmtpClient.cs
index 81a5a04d1b650259b07eee235e198d0c1c9f53ad..ab1bde4ff7fd86789d37c22aa278abeb7f8cd0c1 100644 (file)
@@ -55,15 +55,11 @@ using System.Net.Configuration;
 using System.Configuration;
 using System.Net.Security;
 using System.Security.Authentication;
-#if NET_4_5
 using System.Threading.Tasks;
-#endif
 
 namespace System.Net.Mail {
        public class SmtpClient
-#if NET_4_0
        : IDisposable
-#endif
        {
                #region Fields
 
@@ -125,9 +121,7 @@ namespace System.Net.Mail {
                        if (cfg != null) {
                                this.host = cfg.Network.Host;
                                this.port = cfg.Network.Port;
-#if NET_4_0
                                this.enableSsl = cfg.Network.EnableSsl;
-#endif
                                TargetName = cfg.Network.TargetName;
                                if (this.TargetName == null)
                                        TargetName = "SMTPSVC/" + (host != null ? host : "");
@@ -174,9 +168,7 @@ namespace System.Net.Mail {
                }
 #endif
 
-#if NET_4_0
                public
-#endif
                string TargetName { get; set; }
 
                public ICredentialsByHost Credentials {
@@ -264,7 +256,6 @@ namespace System.Net.Mail {
                #endregion // Events 
 
                #region Methods
-#if NET_4_0
                public void Dispose ()
                {
                        Dispose (true);
@@ -275,7 +266,6 @@ namespace System.Net.Mail {
                {
                        // TODO: We should close all the connections and abort any async operations here
                }
-#endif
                private void CheckState ()
                {
                        if (messageInProcess != null)
@@ -706,13 +696,8 @@ namespace System.Net.Mail {
                        if (message.ReplyToList.Count > 0)
                                SendHeader ("Reply-To", EncodeAddresses (message.ReplyToList));
 
-#if NET_4_0
                        foreach (string s in message.Headers.AllKeys)
                                SendHeader (s, ContentType.EncodeSubjectRFC2047 (message.Headers [s], message.HeadersEncoding));
-#else
-                       foreach (string s in message.Headers.AllKeys)
-                               SendHeader (s, message.Headers [s]);
-#endif
        
                        AddPriorityHeader (message);
 
@@ -740,7 +725,6 @@ namespace System.Net.Mail {
                        Send (new MailMessage (from, to, subject, body));
                }
 
-#if NET_4_5
                public Task SendMailAsync (MailMessage message)
                {
                        var tcs = new TaskCompletionSource<object> ();
@@ -775,7 +759,6 @@ namespace System.Net.Mail {
 
                        source.SetResult (null);
                }
-#endif
 
                private void SendDot()
                {
@@ -798,13 +781,8 @@ namespace System.Net.Mail {
                                CheckCancellation ();
 
                                if (escapeDots) {
-                                       int i;
-                                       for (i = 0; i < line.Length; i++) {
-                                               if (line[i] != '.')
-                                                       break;
-                                       }
-                                       if (i > 0 && i == line.Length) {
-                                               line += ".";
+                                       if (line.Length > 0 && line[0] == '.') {
+                                               line = "." + line;
                                        }
                                }
                                writer.Write (line);