Skip to content

Commit

Permalink
replaced cgi with email.message
Browse files Browse the repository at this point in the history
  • Loading branch information
manobeeslaar authored and lavr committed Jan 8, 2024
1 parent bab1a49 commit c9aef48
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions emails/loader/helpers.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit c9aef48

Please sign in to comment.