From c9aef48bf3362365752c3120e7ea7a16c0d5684b Mon Sep 17 00:00:00 2001 From: "mano.beeslaar" Date: Mon, 8 Jan 2024 15:49:47 +0200 Subject: [PATCH] replaced cgi with email.message --- emails/loader/helpers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/emails/loader/helpers.py b/emails/loader/helpers.py index 3bcc3ac..73578ec 100644 --- a/emails/loader/helpers.py +++ b/emails/loader/helpers.py @@ -1,9 +1,10 @@ # encoding: utf-8 from __future__ import unicode_literals __all__ = ['guess_charset', 'fix_content_type'] +from email.message import Message + import re -import cgi import warnings try: @@ -60,8 +61,9 @@ def guess_charset(headers, html): if headers: content_type = headers['content-type'] if content_type: - _, params = cgi.parse_header(content_type) - r = params.get('charset', None) + msg = Message() + msg.add_header('content-type', content_type) + r = msg.get_param('charset') if r: return r