Skip to content
  • Thomas Sibley's avatar
    Encode dashboard email header values properly for MIME · ac8392aa
    Thomas Sibley authored
    Dashboard names, included in the Subject, may contain Unicode characters
    which need MIME-word encoding first.  MIME::Entity doesn't handle this
    for us.  This was reported by Christian Loos <github@netsandbox.de>.
    
    From and To are passed through encode_utf8() to avoid double encoding
    issues in MIME::Entity, which only handles octets well.  See the full
    rationale in 57ea0c02.
    
    Unlike Subject, From and To don't get the EncodeToMIME treatment because
    MIME-word encoding From and To as an opaque blob is really, really
    wrong.  You need to encode on a per-recipient level using Email::Address
    to parse, otherwise you can lose special chars such as commas into the
    MIME-word.  While From is likely just an email address, To is non-admin
    user-input and may contain commas or an email phrase part or other
    formatting.  See also the bug [1] in ContentAsMIME where we _do_ use
    EncodeToMIME on From and To and the hilarity that ensues for forwards,
    the primary user of ContentAsMIME.
    
    The correct solution for From and To will be to use the encoding logic
    in 4.2-on-4.0/protect-more-chars-while-decoding-headers once it is merged.
    
    [1] http://issues.bestpractical.com/Ticket/Display.html?id=19125
    ac8392aa