From 69d6105e51f6ca1f819267dcc74bf87756977259 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Feb 2012 15:12:53 -0500 Subject: [PATCH 1/3] Site view and unsubscribe link need not to be escaped when included into the body of newsletter Call to BeatifulSoap changed to avoid HTML escaping of included content. --- emencia/django/newsletter/utils/newsletter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/emencia/django/newsletter/utils/newsletter.py b/emencia/django/newsletter/utils/newsletter.py index 6ffb8fc..46e2b56 100644 --- a/emencia/django/newsletter/utils/newsletter.py +++ b/emencia/django/newsletter/utils/newsletter.py @@ -11,11 +11,12 @@ def body_insertion(content, insertion, end=False): if not content.startswith(' Date: Wed, 31 Jul 2013 14:39:29 -0400 Subject: [PATCH 2/3] Fix encoding issues in To: field of messages when unicode caracters are present --- emencia/django/newsletter/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/emencia/django/newsletter/models.py b/emencia/django/newsletter/models.py index bbdddef..c69670b 100644 --- a/emencia/django/newsletter/models.py +++ b/emencia/django/newsletter/models.py @@ -3,6 +3,7 @@ from smtplib import SMTPHeloError from datetime import datetime from datetime import timedelta +from email.header import Header from django.db import models from django.utils.encoding import smart_str @@ -138,7 +139,7 @@ def vcard_format(self): def mail_format(self): if self.first_name and self.last_name: - return '%s %s <%s>' % (self.last_name, self.first_name, self.email) + return Header('%s %s <%s>' % (self.last_name, self.first_name, self.email), 'utf-8').encode() return self.email mail_format.short_description = _('mail format') From 40537b70d99847a53f4fdcf3c8366c676eeff5d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benoit=20Gr=C3=A9goire?= Date: Wed, 31 Jul 2013 15:04:35 -0400 Subject: [PATCH 3/3] Fix url tracking code mangling original url parameters. --- emencia/django/newsletter/views/tracking.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/emencia/django/newsletter/views/tracking.py b/emencia/django/newsletter/views/tracking.py index df4b05c..373caeb 100644 --- a/emencia/django/newsletter/views/tracking.py +++ b/emencia/django/newsletter/views/tracking.py @@ -1,6 +1,6 @@ """Views for emencia.django.newsletter Tracking""" import base64 -from urllib import urlencode +from django.utils.http import urlencode from urlparse import urlparse from urlparse import urlunparse # For Python < 2.6 @@ -53,9 +53,9 @@ def view_newsletter_tracking_link(request, slug, uidb36, token, link_id): query_dict = parse_qs(url_parts.query) query_dict.update({'utm_source': 'newsletter_%s' % newsletter.pk, 'utm_medium': 'mail', - 'utm_campaign': smart_str(newsletter.title)}) + 'utm_campaign': newsletter.title}) url = urlunparse((url_parts.scheme, url_parts.netloc, url_parts.path, - url_parts.params, urlencode(query_dict), url_parts.fragment)) + url_parts.params, urlencode(query_dict, True), url_parts.fragment)) return HttpResponseRedirect(url)