Author: mtredinnick
Date: 2007-10-20 02:53:54 -0500 (Sat, 20 Oct 2007)
New Revision: 6551

Modified:
   django/trunk/django/core/mail.py
Log:
Fixed #5778 -- Changed the way we detect if a string is non-ASCII when creating
email headers. This fixes a problem that was showing up on some (but not all)
systems.


Modified: django/trunk/django/core/mail.py
===================================================================
--- django/trunk/django/core/mail.py    2007-10-20 07:42:34 UTC (rev 6550)
+++ django/trunk/django/core/mail.py    2007-10-20 07:53:54 UTC (rev 6551)
@@ -73,7 +73,7 @@
         if '\n' in val or '\r' in val:
             raise BadHeaderError, "Header values can't contain newlines (got 
%r for header %r)" % (val, name)
         try:
-            val = str(force_unicode(val))
+            val = force_unicode(val).encode('ascii')
         except UnicodeEncodeError:
             if name.lower() in ('to', 'from', 'cc'):
                 result = []
@@ -92,7 +92,7 @@
         if '\n' in val or '\r' in val:
             raise BadHeaderError, "Header values can't contain newlines (got 
%r for header %r)" % (val, name)
         try:
-            val = str(force_unicode(val))
+            val = force_unicode(val).encode('ascii')
         except UnicodeEncodeError:
             if name.lower() in ('to', 'from', 'cc'):
                 result = []


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to