Changeset - fbc588a09811
[Not reviewed]
default
0 1 0
Mads Kiilerich - 8 years ago 2017-05-30 02:59:45
mads@kiilerich.com
email: don't crash on sending mails with unicode comments without appropriate environment configuration (Issue #275)

For example, on Linux, running `gearbox serve` with LANG=C, would crash in:

File ".../kallithea/lib/celerylib/tasks.py", line 307, in send_email
% (' '.join(recipients), headers, subject, body, html_body))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 224: ordinal not in range(128)

Replacing render with render_unicode works in this case ... but there might be
other problems elsewhere.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/model/notification.py
Show inline comments
 
@@ -321,25 +321,25 @@ class EmailNotificationModel(object):
 
        email_template = self._tmpl_lookup.get_template(base)
 
        # translator and helpers inject
 
        _kwargs = {'_': _,
 
                   'h': h,
 
                   'c': c}
 
        _kwargs.update(kwargs)
 
        if content_type == 'html':
 
            _kwargs.update({
 
                "color_text": "#202020",
 
                "color_emph": "#395fa0",
 
                "color_link": "#395fa0",
 
                "color_border": "#ddd",
 
                "color_background_grey": "#f9f9f9",
 
                "color_button": "#395fa0",
 
                "monospace_style": "font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace",
 
                "sans_style": "font-family:Helvetica,Arial,sans-serif",
 
                })
 
            _kwargs.update({
 
                "default_style": "%(sans_style)s;font-weight:200;font-size:14px;line-height:17px;color:%(color_text)s" % _kwargs,
 
                "comment_style": "%(monospace_style)s;white-space:pre-wrap" % _kwargs,
 
                "emph_style": "font-weight:600;color:%(color_emph)s" % _kwargs,
 
                })
 

	
 
        log.debug('rendering tmpl %s with kwargs %s', base, _kwargs)
 
        return email_template.render(**_kwargs)
 
        return email_template.render_unicode(**_kwargs)
0 comments (0 inline, 0 general)