Author: atsushi
Date: 2007-12-05 04:49:37 -0500 (Wed, 05 Dec 2007)
New Revision: 90740
Modified:
trunk/mcs/class/System/System.Net.Mail/Attachment.cs
trunk/mcs/class/System/System.Net.Mail/ChangeLog
trunk/mcs/class/System/System.Net.Mail/MailMessage.cs
trunk/mcs/class/System/System.Net.Mime/ChangeLog
trunk/mcs/class/System/System.Net.Mime/ContentType.cs
Log:
2007-12-05 Atsushi Enomoto <[EMAIL PROTECTED]>
* Attachment.cs : use correct TransferEncoding when (Text)Encoding
is specified.
* MailMessage.cs : ContentTransferEncoding implementation went into
ContentType.
* ContentType.cs : added GuessTransferEncoding() to guess correct
encoding type for sys.net.mail.Attachment.
Here UTF8Encoding should not include BOM.
Modified: trunk/mcs/class/System/System.Net.Mail/Attachment.cs
===================================================================
--- trunk/mcs/class/System/System.Net.Mail/Attachment.cs 2007-12-05
09:32:12 UTC (rev 90739)
+++ trunk/mcs/class/System/System.Net.Mail/Attachment.cs 2007-12-05
09:49:37 UTC (rev 90740)
@@ -138,7 +138,7 @@
sw.Flush ();
ms.Position = 0;
Attachment a = new Attachment (ms, name, mediaType);
- a.TransferEncoding = TransferEncoding.QuotedPrintable;
+ a.TransferEncoding = ContentType.GuessTransferEncoding
(contentEncoding);
return a;
}
Modified: trunk/mcs/class/System/System.Net.Mail/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net.Mail/ChangeLog 2007-12-05 09:32:12 UTC
(rev 90739)
+++ trunk/mcs/class/System/System.Net.Mail/ChangeLog 2007-12-05 09:49:37 UTC
(rev 90740)
@@ -1,3 +1,10 @@
+2007-12-05 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * Attachment.cs : use correct TransferEncoding when (Text)Encoding
+ is specified.
+ * MailMessage.cs : ContentTransferEncoding implementation went into
+ ContentType.
+
2007-12-04 Arina Itkes <[EMAIL PROTECTED]>
* SmtpException.cs, SmtpFailedRecipientException.cs,
Modified: trunk/mcs/class/System/System.Net.Mail/MailMessage.cs
===================================================================
--- trunk/mcs/class/System/System.Net.Mail/MailMessage.cs 2007-12-05
09:32:12 UTC (rev 90739)
+++ trunk/mcs/class/System/System.Net.Mail/MailMessage.cs 2007-12-05
09:49:37 UTC (rev 90740)
@@ -145,17 +145,7 @@
}
internal TransferEncoding ContentTransferEncoding {
- get {
- Encoding enc = BodyEncoding;
- if (Encoding.ASCII.Equals (enc))
- return TransferEncoding.SevenBit;
- else if (Encoding.UTF8.CodePage == enc.CodePage
||
- Encoding.Unicode.CodePage == enc.CodePage ||
- Encoding.UTF32.CodePage == enc.CodePage)
- return TransferEncoding.Base64;
- else
- return TransferEncoding.QuotedPrintable;
- }
+ get { return ContentType.GuessTransferEncoding
(BodyEncoding); }
}
public Encoding BodyEncoding {
Modified: trunk/mcs/class/System/System.Net.Mime/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net.Mime/ChangeLog 2007-12-05 09:32:12 UTC
(rev 90739)
+++ trunk/mcs/class/System/System.Net.Mime/ChangeLog 2007-12-05 09:49:37 UTC
(rev 90740)
@@ -1,3 +1,9 @@
+2007-12-05 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * ContentType.cs : added GuessTransferEncoding() to guess correct
+ encoding type for sys.net.mail.Attachment.
+ Here UTF8Encoding should not include BOM.
+
2007-10-22 Atsushi Enomoto <[EMAIL PROTECTED]>
* ContentType.cs : moved couple of encoding stuff to here.
Modified: trunk/mcs/class/System/System.Net.Mime/ContentType.cs
===================================================================
--- trunk/mcs/class/System/System.Net.Mime/ContentType.cs 2007-12-05
09:32:12 UTC (rev 90739)
+++ trunk/mcs/class/System/System.Net.Mime/ContentType.cs 2007-12-05
09:49:37 UTC (rev 90740)
@@ -40,6 +40,7 @@
public class ContentType
{
#region Fields
+ static Encoding utf8unmarked;
string mediaType;
StringDictionary parameters = new StringDictionary ();
@@ -104,6 +105,14 @@
#region Properties
+ static Encoding UTF8Unmarked {
+ get {
+ if (utf8unmarked == null)
+ utf8unmarked = new UTF8Encoding (false);
+ return utf8unmarked;
+ }
+ }
+
public string Boundary {
get { return parameters["boundary"]; }
set { parameters["boundary"] = value; }
@@ -178,10 +187,22 @@
{
for (int i = 0; i < s.Length; i++)
if (s [i] >= '\u0080')
- return Encoding.UTF8;
+ return UTF8Unmarked;
return Encoding.ASCII;
}
+ internal static TransferEncoding GuessTransferEncoding
(Encoding enc)
+ {
+ if (Encoding.ASCII.Equals (enc))
+ return TransferEncoding.SevenBit;
+ else if (Encoding.UTF8.CodePage == enc.CodePage ||
+ Encoding.Unicode.CodePage == enc.CodePage ||
+ Encoding.UTF32.CodePage == enc.CodePage)
+ return TransferEncoding.Base64;
+ else
+ return TransferEncoding.QuotedPrintable;
+ }
+
internal static string EncodeSubjectRFC2047 (string s, Encoding
enc)
{
if (s == null || Encoding.ASCII.Equals (enc))
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches