summaryrefslogtreecommitdiffstats
path: root/apps/patchwork/bin/parsemail.py
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2008-10-23 14:22:33 +1100
committerJeremy Kerr <jk@ozlabs.org>2008-10-23 14:22:33 +1100
commitd45218b2e3894211e11313820bea9f59677c4bf2 (patch)
tree09968c074fbd82ad55fd21b1385092bcc577aa82 /apps/patchwork/bin/parsemail.py
parent64b4f583066dc0757a82257d1dd2c97d451ce7d4 (diff)
downloadpatchwork-d45218b2e3894211e11313820bea9f59677c4bf2.tar.bz2
patchwork-d45218b2e3894211e11313820bea9f59677c4bf2.tar.xz
[parser] Handle patches with no content charset defined
If we don't have an incoming charset defined, assume utf-8. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'apps/patchwork/bin/parsemail.py')
-rwxr-xr-xapps/patchwork/bin/parsemail.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/apps/patchwork/bin/parsemail.py b/apps/patchwork/bin/parsemail.py
index 9aaaa9d..772728e 100755
--- a/apps/patchwork/bin/parsemail.py
+++ b/apps/patchwork/bin/parsemail.py
@@ -138,10 +138,16 @@ def find_content(project, mail):
continue
payload = part.get_payload(decode=True)
- if not isinstance(payload, unicode):
- payload = unicode(payload, part.get_content_charset())
+ charset = part.get_content_charset()
subtype = part.get_content_subtype()
+ # if we don't have a charset, assume utf-8
+ if charset is None:
+ charset = 'utf-8'
+
+ if not isinstance(payload, unicode):
+ payload = unicode(payload, charset)
+
if subtype in ['x-patch', 'x-diff']:
patchbuf = payload