emencia / emencia-django-newsletter

An app for sending newsletter by email to a contact list.
189 stars 72 forks source link

Accent in newsletter title makes followinga link fail #28

Closed alexgarel closed 13 years ago

alexgarel commented 13 years ago

If newsletter title has an accent (non ascii char) we get a traceback :

 File "/home/www/emencia-django-newsletter/emencia/django/newsletter/views/tracking.py", line 56, in view_newsletter_tracking_link
    url_parts.params, urlencode(query_dict), url_parts.fragment))
  File "/usr/lib/python2.6/urllib.py", line 1269, in urlencode
    v = quote_plus(str(v))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 9: ordinal not in range(128)

The problem is that we have a unicode in query_dict instead of a string.

So I propose to change line 54 to encode string in utf-8

-                        'utm_campaign': newsletter.title})
+                        'utm_campaign': newsletter.title.encode('utf-8')})
Fantomas42 commented 13 years ago

Thank you for the report,

fixed in Fantomas42/emencia-django-newsletter@32ce490fe09a6e478fc65a46ef9ee6fc672e6975