From 5960a749b88d64b2d0587e090d3f47be554d4f9d Mon Sep 17 00:00:00 2001 From: hernani Date: Thu, 3 Jun 2010 17:08:07 +0000 Subject: [PATCH] Solves several email encoding issues. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@362 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- .../default/templates/notifications/answeraccepted.html | 2 +- forum/skins/default/templates/notifications/newanswer.html | 2 +- forum/skins/default/templates/notifications/newcomment.html | 2 +- forum/utils/html.py | 2 +- forum/utils/mail.py | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/forum/skins/default/templates/notifications/answeraccepted.html b/forum/skins/default/templates/notifications/answeraccepted.html index 8dac6ce..7170a5d 100644 --- a/forum/skins/default/templates/notifications/answeraccepted.html +++ b/forum/skins/default/templates/notifications/answeraccepted.html @@ -5,7 +5,7 @@ app_name = settings.APP_SHORT_NAME answer_author = answer.author.username question = answer.question - question_title = question.title + question_title = html.mark_safe(question.title) accepted_by = answer.nstate.accepted.by.username {% enddeclare %} diff --git a/forum/skins/default/templates/notifications/newanswer.html b/forum/skins/default/templates/notifications/newanswer.html index d258cde..947de0c 100644 --- a/forum/skins/default/templates/notifications/newanswer.html +++ b/forum/skins/default/templates/notifications/newanswer.html @@ -5,7 +5,7 @@ app_name = settings.APP_SHORT_NAME answer_author = answer.author.username question = answer.question - question_title = question.title + question_title = html.mark_safe(question.title) safe_body = html.html2text(answer.html) {% enddeclare %} diff --git a/forum/skins/default/templates/notifications/newcomment.html b/forum/skins/default/templates/notifications/newcomment.html index a4859a4..043a24d 100644 --- a/forum/skins/default/templates/notifications/newcomment.html +++ b/forum/skins/default/templates/notifications/newcomment.html @@ -8,7 +8,7 @@ post_author = post.author.username comment_author = comment.author question_url = question.get_absolute_url() - question_title = question.title + question_title = html.mark_safe(question.title) safe_body = html.html2text(comment.comment) {% enddeclare %} diff --git a/forum/utils/html.py b/forum/utils/html.py index 16d5ac6..e7ca42c 100644 --- a/forum/utils/html.py +++ b/forum/utils/html.py @@ -55,7 +55,7 @@ def html2text(s, ignore_tags=(), indent_width=4, page_width=80): parser.feed(s) parser.close() parser.generate() - return parser.result + return mark_safe(parser.result) def buildtag(name, content, **attrs): return mark_safe('<%s %s>%s' % (name, " ".join('%s="%s"' % i for i in attrs.items()), content)) diff --git a/forum/utils/mail.py b/forum/utils/mail.py index 7e4beab..6536a44 100644 --- a/forum/utils/mail.py +++ b/forum/utils/mail.py @@ -158,7 +158,7 @@ def create_and_send_mail_messages(messages): for recipient, subject, html, text, media in messages: msgRoot = MIMEMultipart('related') - msgRoot.set_charset('utf-8') + #msgRoot.set_charset('utf-8') msgRoot['Subject'] = subject msgRoot['From'] = sender msgRoot['To'] = '%s <%s>' % (recipient.username, recipient.email) @@ -167,8 +167,8 @@ def create_and_send_mail_messages(messages): msgAlternative = MIMEMultipart('alternative') msgRoot.attach(msgAlternative) - msgAlternative.attach(MIMEText(text)) - msgAlternative.attach(MIMEText(html, 'html')) + msgAlternative.attach(MIMEText(text.encode('utf-8'), _charset='utf-8')) + msgAlternative.attach(MIMEText(html.encode('utf-8'), 'html', _charset='utf-8')) for alias, location in media.items(): fp = open(location, 'rb') -- 2.39.5