Fix dot stuffing in SmtpClient
authormeum <meum@users.noreply.github.com>
Tue, 23 Jun 2015 15:03:59 +0000 (17:03 +0200)
committermeum <meum@users.noreply.github.com>
Tue, 23 Jun 2015 15:03:59 +0000 (17:03 +0200)
As per RFC2821 section 4.5.2:
   -  Before sending a line of mail text, the SMTP client checks the
      first character of the line.  If it is a period, one additional
      period is inserted at the beginning of the line.

mcs/class/System/System.Net.Mail/SmtpClient.cs

index 278e6e3426f83c0cf5c3b9d57cb971aa7a458f9d..ab1bde4ff7fd86789d37c22aa278abeb7f8cd0c1 100644 (file)
@@ -781,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);