Bug#907891: perl: MIME-Q (RFC2047 eMail header) encoding broken since post-stretch

Thorsten Glaser t.glaser at tarent.de
Mon Sep 3 22:43:02 BST 2018


Russ Allbery dixit:

>Thorsten Glaser <tg at mirbsd.de> writes:
>
>> (sid)$ printf '%s' 'Subject: UNNAMED PROJECT branch bnewplus updated. f9dfb215c29bc17b5ca12c0e8bb509aa4949787e' | perl -C7 -0777 -Mutf8 -MEncode -e "print encode('MIME-Q', <>);"; echo
>> =?UTF-8?Q?Subject=3A_UNNAMED_PROJECT_branch_bnewplus_updated=2E_f9dfb215c?=
>>  =?UTF-8?Q?29bc17b5ca12c0e8bb509aa4949787e?=
>
>This doesn't directly address the rest of your bug report, but I'm fairly
>sure that including the email header in the text you're encoding is a bug
>in your code.  RFC 2047 encoding is defined on a string, and the encoder
>has no way of knowing that the initial "Subject: " is magical and should
>be treated not as part of the string.  It could well be part of the
>content of the header field.

This is true, but the encoder API must normally, if it requires the
name of the header to *not* be part of the to-be-encoded string, have
a provision for the caller to provide the length of it (PHP’s does,
you can have the header name inline or separate passing its length).

This is because the encoding scheme is like:

Subject: =?UTF-8?B?xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?=
 =?UTF-8?B?xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?=
 =?UTF-8?B?xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?=
 =?UTF-8?B?xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?=
 =?UTF-8?B?xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?=

That is, the first line MUST be shorter, for the 76 octet limit.

AIUI, the encode('MIME-Q', …) API doesn’t, so it must cope with
the leading header field (actually, it must *require* it).

bye,
//mirabilos
-- 
tarent solutions GmbH
Rochusstraße 2-4, D-53123 Bonn • http://www.tarent.de/
Tel: +49 228 54881-393 • Fax: +49 228 54881-235
HRB 5168 (AG Bonn) • USt-ID (VAT): DE122264941
Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg




More information about the Perl-maintainers mailing list