Skip to content

Invalid utf-7 data in body causes exceptions #1404

@pdg137

Description

@pdg137

The following results in an Encoding::InvalidByteSequenceError:

Mail::Part.new("Content-Type: text/plain; charset=\"utf-7\"\r\n\r\n&5g-").decoded

The equivalent using quoted-printable makes use of the replacement character:

irb(main):005:0> Mail::Part.new("Content-Type: text/plain; charset=\"utf-8\"\r\n" +
                                "Content-Transfer-Encoding: quoted-printable\r\n\r\n=E6").decoded
=> "�"

There are explicit tests that in B encodings we capture encoding errors and revert to displaying the raw text, but there's nothing trapping such errors when decoding the message body.

Should a utf-7 body work like quoted-printable or like a utf-7 header? In any case, it seems like a bad idea to let encoding-related exceptions bubble up to the application.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions