Skip to content

Commit 906bd5d

Browse files
manobeeslaarlavr
authored andcommitted
replaced cgi with email.message
1 parent bab1a49 commit 906bd5d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

emails/loader/helpers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# encoding: utf-8
22
from __future__ import unicode_literals
33
__all__ = ['guess_charset', 'fix_content_type']
4+
from email.message import Message
5+
46

57
import re
6-
import cgi
78
import warnings
89

910
try:
@@ -60,8 +61,9 @@ def guess_charset(headers, html):
6061
if headers:
6162
content_type = headers['content-type']
6263
if content_type:
63-
_, params = cgi.parse_header(content_type)
64-
r = params.get('charset', None)
64+
msg = Message()
65+
msg.add_header('content-type', content_type)
66+
r = msg.get_param('charset')
6567
if r:
6668
return r
6769

0 commit comments

Comments
 (0)