1. Christian Ebert
  2. muttils

Commits

Christian Ebert  committed 04f5de3

viewhtmlmsg: for charset add <head> if not present (#2)

  • Participants
  • Parent commits 6ac36e5
  • Branches default

Comments (0)

Files changed (1)

File muttils/viewhtmlmsg.py

View file
             charset = html.get_param('charset')
             html = html.get_payload(decode=True)
             if charset:
-                html = html.replace('<head>', '<head><meta charset="%s">' % charset)
+                charsetmeta = '<meta charset="%s">' % charset
+                if '<head>' in html:
+                    html = html.replace('<head>', '<head>%s' % charsetmeta)
+                else:
+                    html = '<head>%s</head>%s' % (charsetmeta, html)
             fc = 0
             for part in msg.walk():
                 fc += 1