Skip to content

Headers should not use charset specified in Content-Type: #410

Open
@ConradIrwin

Description

@ConradIrwin

Headers in email are defined to be ASCII only (or UTF-8 if you're experimenting with RFC 5335). They should not be any other character encoding.

At the moment the mail gem decodes headers that appear after the Content-Type header with the same charset as specified there. This is wrong, and causes strange errors with some character encodings:

pry> Mail.new("Content-Type: text/plain; charset=iso-2022-jp\r\nSubject: Test\r\n\r\nTest\r\n").encoded
Encoding::CompatibilityError: incompatible encoding regexp match (US-ASCII regexp with ISO-2022-JP string)
from /home/conrad/.rvm/gems/ruby-1.9.3-p194@foo/bundler/gems/mail-de4eec71b0b2/lib/mail/fields/unstructured_field.rb:179:in `gsub!'

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions