On Mon, 2013-02-11 at 09:34 +0100, Michael Vogt wrote:
> On Sat, Feb 09, 2013 at 02:21:27PM +0000, Sam Morris wrote:
> > Package: unattended-upgrades
> > Version: 0.79.4
> > Severity: minor
> 
> Thanks for your bugreport.
> 
> [..] 
> > My MUA formats the final part of the unattended-upgrades result mail as
> > follows:
> [..]
> > Correctly encoded, it should look like this:
> > 
> >     Allowed origins are: ['o=3DDebian,n=3Dwheezy', 
> > 'o=3DDebian,n=3Dwheezy-updates', 
> > 'o=3DDebian,n=3Dwheezy,l=3DDebian-Security', 
> > 'origin=3DDebian,archive=3Dstable,label=3DDebian-Security']
> 
> Indeed, I just verified the issue and fixed it in trunk. It should
> work correctly there, if you want to give test-run it just get the
> latest version from bzr via:
> $ bzr branch lp:unattended-upgrades
> and run it from the local checkout.
> 
> Cheers,
>  Michael

Hi Michael, the fix looks good. As an alternative, you can avoid having
to explicitly encode the message body yourself by moving msg.set_charset
to after msg.set_payload. For example:

        # coding=utf-8
        from email import Charset
        from email.header import Header
        from email.message import Message
        
        m = Message ()
        m['To'] = Header (u'someøne')
        m.set_payload ('body=neéds=CTE')
        
        c = Charset.Charset ('utf-8')
        c.body_encoding = Charset.QP
        m.set_charset (c)
        
        print m.as_string ()

This outputs:

        To: =?utf-8?q?some=C3=B8ne?=
        MIME-Version: 1.0
        Content-Type: text/plain; charset="utf-8"
        Content-Transfer-Encoding: quoted-printable
        
        body=3Dne=C3=A9ds=3DCTE

Including the bonus unintelligible but 7-bit clean To header. OTOH,
perhaps it's better to be explicit, since the ordering dependency isn't
obvious to someone who isn't familiar with the Python email module.

Anyway, cheers for the timely fix!

-- 
Sam Morris <https://robots.org.uk/>
3412 EA18 1277 354B 991B  C869 B219 7FDB 5EA0 1078

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to