diff --git a/mbox2web b/mbox2web index ac973a1..6f7d273 100755 --- a/mbox2web +++ b/mbox2web @@ -207,7 +207,10 @@ def render_body(msg, extra=None): return bodytmpl.render(context) def render_text_html(msg, extra=None): htmlpart = HTMLPart(extra) - htmlpart.feed(msg.get_payload(decode=True).decode(msg.get_charset() or "iso-8859-1")) + ct_params = dict(msg.get_params()) + charset = ct_params.get("charset", "iso-8859-1") + raw_text = msg.get_payload(decode=True).decode(charset, errors="replace") + htmlpart.feed(raw_text) bodytmpl = jenv.get_template("body_text_html.html") context = { "body": jinja2.Markup(htmlpart.as_string())