• Alex Vandiver's avatar
    Ensure all MIME::Entity headers are UTF-8 encoded bytes · 41d084f1
    Alex Vandiver authored
    Placing wide characters into MIME::Entity objects can lead to
    double-encoding, as discovered most recently in d469cacc.  Explicitly
    decode all headers as UTF-8 when retrieving them with ->get(), and
    encode them as UTF-8 before updating them with ->set() or ->replace().
    This also applies to headers passed to ->build().  The only exceptions
    to this are fixed strings in the source (which, in the absence of "use
    utf8", are always bytes).
    While the majority of these headers will never have wide characters in
    them, always decoding and encoding ensures the proper disipline to
    guarantee that strings with the "UTF8" flag do not get placed in a
    header, which can cause double-encoding.