X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=inject-mbox.py;h=3faf3d64cbcb337c58c4072172bd258e17546284;hb=a4794f3aa2af3183e2429f67188d50a477ab7a3a;hp=7a5539c060d7960293b4d0b658c2eb528d32f911;hpb=5baa46c18d0064fe29a2a0cf7c8a6b28a40d3b0a;p=patchq.git diff --git a/inject-mbox.py b/inject-mbox.py index 7a5539c..3faf3d6 100755 --- a/inject-mbox.py +++ b/inject-mbox.py @@ -28,6 +28,15 @@ processed = 0 def inject(m): global processed + # Decode the subject line and store it back in the email as UTF-8. + # This saves a lot of effort later on, even though it's not + # strictly RFC822 compliant. + # https://stackoverflow.com/questions/7331351/python-email-header-decoding-utf-8/7331577#7331577 + subj = m['Subject'] + subj = email.header.decode_header(subj) + subj = ''.join([ unicode(t[0], t[1] or 'ASCII') for t in subj ]) + m['Subject'] = subj + print("Injecting %s" % m['Subject']) channel.basic_publish(exchange = 'patchq_input',