2007-12-06 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Thu, 6 Dec 2007 14:22:51 +0000 (14:22 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Thu, 6 Dec 2007 14:22:51 +0000 (14:22 -0000)
* AlternateView.cs : supply charset info for ContentType.
* SmtpClient.cs : for ToQuotedPrintable() input, don't use utf8
  StreamReader to get input string. Just use Encoding.GetBytes().
  Fixed bug #346162.

svn path=/trunk/mcs/; revision=90809

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

index 1502b8a40d98cbc26d4c2d3bbdb5477c6d5f7597..8d178b6f6cc71c1dbb88e73fab0e9e6e054d8fdb 100644 (file)
@@ -120,7 +120,10 @@ namespace System.Net.Mail {
                        if (encoding == null)
                                encoding = Encoding.UTF8;
                        MemoryStream ms = new MemoryStream (encoding.GetBytes (content));
-                       AlternateView av = new AlternateView (ms, mediaType);
+                       ContentType ct = new ContentType ();
+                       ct.MediaType = mediaType;
+                       ct.CharSet = encoding.HeaderName;
+                       AlternateView av = new AlternateView (ms, ct);
                        av.TransferEncoding = TransferEncoding.QuotedPrintable;
                        return av;
                }
index c99c417ed10faa7a834635f7dd6358bef9639aa6..d5e471420f8addd1daf2f851df68314885df19e0 100644 (file)
@@ -1,3 +1,10 @@
+2007-12-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AlternateView.cs : supply charset info for ContentType.
+       * SmtpClient.cs : for ToQuotedPrintable() input, don't use utf8
+         StreamReader to get input string. Just use Encoding.GetBytes().
+         Fixed bug #346162.
+
 2007-12-05  Atsushi Enomoto  <atsushi@ximian.com>
 
        * MailMessage.cs : fixing cosmetic .net compatibility. Automatically
index ff1f7d01e275e9d3b2ee6bc00727559e7d4585cc..8cfa80807f5b04d076475c83bee9788565415118 100644 (file)
@@ -774,9 +774,9 @@ try {
 #endif
                                        break;
                                case TransferEncoding.QuotedPrintable:
-                                       StreamReader sr = new StreamReader (av.ContentStream);
-                                       Encoding encoding = contentType.CharSet != null ? Encoding.GetEncoding (contentType.CharSet) : Encoding.ASCII;
-                                       SendData (ToQuotedPrintable (sr.ReadToEnd (), encoding));
+                                       byte [] bytes = new byte [av.ContentStream.Length];
+                                       av.ContentStream.Read (bytes, 0, bytes.Length);
+                                       SendData (ToQuotedPrintable (bytes));
                                        break;
                                case TransferEncoding.SevenBit:
                                case TransferEncoding.Unknown:
@@ -818,9 +818,9 @@ try {
 #endif
                                        break;
                                case TransferEncoding.QuotedPrintable:
-                                       StreamReader sr = new StreamReader (lr.ContentStream);
-                                       Encoding encoding = contentType.CharSet != null ? Encoding.GetEncoding (contentType.CharSet) : Encoding.ASCII;
-                                       SendData (ToQuotedPrintable (sr.ReadToEnd (), encoding));
+                                       byte [] bytes = new byte [lr.ContentStream.Length];
+                                       lr.ContentStream.Read (bytes, 0, bytes.Length);
+                                       SendData (ToQuotedPrintable (bytes));
                                        break;
                                case TransferEncoding.SevenBit:
                                case TransferEncoding.Unknown:
@@ -853,9 +853,9 @@ try {
 #endif
                                        break;
                                case TransferEncoding.QuotedPrintable:
-                                       StreamReader sr = new StreamReader (att.ContentStream);
-                                       Encoding encoding = contentType.CharSet != null ? Encoding.GetEncoding (contentType.CharSet) : Encoding.ASCII;
-                                       SendData (ToQuotedPrintable (sr.ReadToEnd (), encoding));
+                                       byte [] bytes = new byte [att.ContentStream.Length];
+                                       att.ContentStream.Read (bytes, 0, bytes.Length);
+                                       SendData (ToQuotedPrintable (bytes));
                                        break;
                                case TransferEncoding.SevenBit:
                                case TransferEncoding.Unknown: