Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site view and unsubscribe link need not to be escaped when included into... #77

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion emencia/django/newsletter/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')

Expand Down
5 changes: 3 additions & 2 deletions emencia/django/newsletter/utils/newsletter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ def body_insertion(content, insertion, end=False):
if not content.startswith('<body'):
content = '<body>%s</body>' % content
soup = BeautifulSoup(content)
soup_ins = BeautifulSoup(insertion)

if end:
soup.body.append(insertion)
soup.body.append(soup_ins)
else:
soup.body.insert(0, insertion)
soup.body.insert(0, soup_ins)

if USE_PRETTIFY:
return soup.prettify()
Expand Down
6 changes: 3 additions & 3 deletions emencia/django/newsletter/views/tracking.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)


Expand Down