]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/bin/parsemail.py
[parser] Convert patch content to unicode before parsing
[patchwork] / apps / patchwork / bin / parsemail.py
index 2acceb5836a871835a42eff65f99360e078b6823..9aaaa9d9421a87405d566a8b691d11e324d2886a 100755 (executable)
@@ -138,11 +138,14 @@ def find_content(project, mail):
             continue
 
         payload = part.get_payload(decode=True)
+        if not isinstance(payload, unicode):
+            payload = unicode(payload, part.get_content_charset())
+        subtype = part.get_content_subtype()
 
-        if part.get_content_subtype() == 'x-patch':
+        if subtype in ['x-patch', 'x-diff']:
             patchbuf = payload
 
-        if part.get_content_subtype() == 'plain':
+        elif subtype == 'plain':
             if not patchbuf:
                 (patchbuf, c) = parse_patch(payload)
             else: